From eb39018fd0b5751dd90fabce905997e52f2ffecd Mon Sep 17 00:00:00 2001 From: indexzero Date: Tue, 7 Sep 2010 16:15:04 -0400 Subject: [PATCH] [api] Integrated a little more from Mikeal to make our return headers consistent --- lib/node-http-proxy.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/node-http-proxy.js b/lib/node-http-proxy.js index c7b0e80..0505031 100644 --- a/lib/node-http-proxy.js +++ b/lib/node-http-proxy.js @@ -81,7 +81,6 @@ var createProxy = function () { server.emit('route', req, res, function (port, hostname) { var p = manager.getPool(port, hostname); - req.headers.Connection = req.headers.Connection || 'close'; p.request(req.method, req.url, req.headers, function (reverse_proxy) { var data = ''; reverse_proxy.on('error', function (err) { @@ -113,6 +112,11 @@ var createProxy = function () { // Add a listener for the reverse_proxy response event reverse_proxy.addListener('response', function (response) { + if (response.headers.connection) { + if (req.headers.connection) response.headers.connection = req.headers.connection; + else response.headers.connection = 'close'; + } + // These two listeners are for testability and observation // of what's passed back from the target server response.addListener('data', function (chunk) {