diff --git a/lib/http.js b/lib/http.js index 7ad7765a668..470981bb853 100644 --- a/lib/http.js +++ b/lib/http.js @@ -1306,8 +1306,7 @@ ClientRequest.prototype.onSocket = function(socket) { return true; } - if (req.shouldKeepAlive && res.headers.connection !== 'keep-alive' && - !req.upgradeOrConnect) { + if (req.shouldKeepAlive && !shouldKeepAlive && !req.upgradeOrConnect) { // Server MUST respond with Connection:keep-alive for us to enable it. // If we've been upgraded (via WebSockets) we also shouldn't try to // keep the connection open.