Skip to content

Commit af9eb06

Browse files
committed
Merge pull request #298 from Kami/connection_keep_alive_on_1_1
If HTTP 1.1 is used and backend doesn't return 'Connection' header, expicitly return Connection: keep-alive.
2 parents 28a3b0a + 850171c commit af9eb06

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

Diff for: lib/node-http-proxy/http-proxy.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,14 @@ HttpProxy.prototype.proxyRequest = function (req, res, buffer) {
240240
//
241241
if (!response.headers.connection) {
242242
if (req.headers.connection) { response.headers.connection = req.headers.connection }
243-
else { response.headers.connection = 'close' }
243+
else {
244+
if (req.httpVersion === '1.0') {
245+
response.headers.connection = 'close'
246+
}
247+
else if (req.httpVersion === '1.1') {
248+
response.headers.connection = 'keep-alive'
249+
}
250+
}
244251
}
245252

246253
// Remove `Transfer-Encoding` header if client's protocol is HTTP/1.0

0 commit comments

Comments
 (0)