Skip to content

Commit 850171c

Browse files
committed
If HTTP 1.1 is used and backend doesn't return 'Connection' header, explicitly
return Connection: keep-alive.
1 parent 4f6387c commit 850171c

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lib/node-http-proxy/http-proxy.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,14 @@ HttpProxy.prototype.proxyRequest = function (req, res, buffer) {
236236
//
237237
if (response.headers.connection) {
238238
if (req.headers.connection) { response.headers.connection = req.headers.connection }
239-
else { response.headers.connection = 'close' }
239+
else {
240+
if (req.httpVersion === '1.0') {
241+
response.headers.connection = 'close'
242+
}
243+
else if (req.httpVersion === '1.1') {
244+
response.headers.connection = 'keep-alive'
245+
}
246+
}
240247
}
241248

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

0 commit comments

Comments
 (0)