Skip to content
Browse files

As RFC 2616 says we should, assume that servers will provide a persis…

…tent connection by default.

> A significant difference between HTTP/1.1 and earlier versions of
> HTTP is that persistent connections are the default behavior of any
> HTTP connection. That is, unless otherwise indicated, the client
> SHOULD assume that the server will maintain a persistent connection,
> even after error responses from the server.

> HTTP/1.1 applications that do not support persistent connections MUST
> include the "close" connection option in every message.
  • Loading branch information...
1 parent f2f3028 commit cde4c24d51bf35ca2a25fc8d85a306081e122dd3 @thejh committed Dec 29, 2011
Showing with 9 additions and 1 deletion.
  1. +9 −1 lib/http.js
View
10 lib/http.js
@@ -1202,7 +1202,15 @@ ClientRequest.prototype.onSocket = function(socket) {
return true;
}
- if (req.shouldKeepAlive && res.headers.connection !== 'keep-alive' && !req.upgraded) {
+ if (req.shouldKeepAlive && !req.upgraded &&
+ (res.httpVersion === '1.1' ?
+ // in HTTP/1.1, default is keep-alive
+ (res.headers.connection && res.headers.connection !== 'keep-alive')
+ :
+ // in HTTP/1.0, default is no keep-alive
+ (res.headers.connection !== 'keep-alive')
+ )
+ ) {
// 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.

0 comments on commit cde4c24

Please sign in to comment.
Something went wrong with that request. Please try again.