From 850171cdc41cb93343f7c31f650ac908a8d2dacb Mon Sep 17 00:00:00 2001 From: Tomaz Muraus Date: Thu, 16 Aug 2012 21:47:56 -0700 Subject: [PATCH] If HTTP 1.1 is used and backend doesn't return 'Connection' header, explicitly return Connection: keep-alive. --- lib/node-http-proxy/http-proxy.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/node-http-proxy/http-proxy.js b/lib/node-http-proxy/http-proxy.js index 5f606e2bb..b47cf1685 100644 --- a/lib/node-http-proxy/http-proxy.js +++ b/lib/node-http-proxy/http-proxy.js @@ -236,7 +236,14 @@ HttpProxy.prototype.proxyRequest = function (req, res, buffer) { // if (response.headers.connection) { if (req.headers.connection) { response.headers.connection = req.headers.connection } - else { response.headers.connection = 'close' } + else { + if (req.httpVersion === '1.0') { + response.headers.connection = 'close' + } + else if (req.httpVersion === '1.1') { + response.headers.connection = 'keep-alive' + } + } } // Remove `Transfer-Encoding` header if client's protocol is HTTP/1.0