Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • N node-http-proxy
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 482
    • Issues 482
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 102
    • Merge requests 102
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • http ... PARTY!
  • node-http-proxy
  • Merge requests
  • !407

Correct keep-alive responses to HTTP 1.0 clients

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Administrator requested to merge github/fork/GUI/master into master Apr 18, 2013
  • Overview 1
  • Commits 2
  • Pipelines 0
  • Changes 3

Created by: GUI

This issue stems from #59 (closed)

Since the proxy requests comes from NodeJS's HTTP 1.1 request client, a backend server may default to setting Connection: keep-alive in its response. However, the real HTTP 1.0 client may not be able to handle that.

Force HTTP 1.0 client's to Connection: close, unless the client explicitly supports keep-alive.

Here's a demonstration of the existing problem with a default nginx install running on port 8082 and the proxy running on port 9999:

httpProxy.createServer(8082, 'localhost').listen(9999);

Straight to nginx with default HTTP 1.0:

$ curl -I --http1.0 'http://127.0.0.1:8082/'
HTTP/1.1 404 Not Found
Server: nginx/1.2.6
Date: Thu, 18 Apr 2013 22:44:51 GMT
Content-Type: text/html
Content-Length: 168
Connection: close

Straight to nginx with HTTP 1.0 and keep-alive header:

$ curl -I --http1.0 -H 'Connection: keep-alive' 'http://127.0.0.1:8082/'
HTTP/1.1 404 Not Found
Server: nginx/1.2.6
Date: Thu, 18 Apr 2013 22:46:22 GMT
Content-Type: text/html
Content-Length: 168
Connection: keep-alive

Default HTTP 1.0 request through the proxy:

$ curl -I --http1.0 'http://127.0.0.1:9999/'
HTTP/1.1 404 Not Found
server: nginx/1.2.6
date: Thu, 18 Apr 2013 22:47:06 GMT
content-type: text/html
content-length: 168
connection: keep-alive

This patch restores nginx's default behavior of only returning Connection: keep-alive for HTTP 1.0 clients if the client explicitly supports it. Otherwise, it will default to Connection: close.

I'm not sure if all backend servers behave this way, but this seems like the correct way to handle it given the fact that the node proxy forces the request to HTTP 1.1 but an HTTP 1.0 client won't support keep-alive by default.

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/GUI/master