Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

If HTTP 1.1 is used and backend doesn't return 'Connection' header, expicitly return Connection: keep-alive. #298

Merged
merged 1 commit into from

3 participants

@Kami

Currently if a backend doesn't return Connection header, http-proxy sets it to Connetion: close regardless of the request HTTP version.

We should respect request HTTP version and if HTTP 1.1 is used, return Connection: keep-alive. *

  • Quoted from the RFC:
...
to indicate that the connection will be kept open for the next request. The Connection header field with a keep-alive keyword must be sent on all requests and responses that wish to continue the persistence. The client sends requests as normal and the server responds as normal, except that all messages containing an entity body must have a length that can be determined without closing the connection (i.e., each message containg an entity body must have a valid Content-Length, be a multipart media type, or be encoded using the "chunked" transfer coding, as described in Section 7.2.2).
...
@travisbot

This pull request passes (merged 850171c into 4f6387c).

@Kami

bump ^^

@indexzero
Owner

Seems reasonable. We'll try to get this merged in soon. We try to perform maintenance in groups to make releases more stable, so apologies if it is not immediate.

@Kami

OK, thanks for the heads up.

@indexzero indexzero merged commit af9eb06 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 17, 2012
  1. @Kami

    If HTTP 1.1 is used and backend doesn't return 'Connection' header, e…

    Kami authored
    …xplicitly
    
    return Connection: keep-alive.
This page is out of date. Refresh to see the latest.
Showing with 8 additions and 1 deletion.
  1. +8 −1 lib/node-http-proxy/http-proxy.js
View
9 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
Something went wrong with that request. Please try again.