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
  • !742

Set `Content-Length` header for OPTIONS requests

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Administrator requested to merge github/fork/jugglinmike/option-content-length into master Nov 24, 2014
  • Overview 2
  • Commits 1
  • Pipelines 0
  • Changes 2

Created by: jugglinmike

Note also that this change was previously suggested as part of the resolution of https://github.com/nodejitsu/node-http-proxy/pull/338, but it never made it to master.

I'm not so happy about special-casing individual HTTP verbs like this, and I doubt the maintainers are, either. A better solution would involve disabling the default Node.js behavior described in the commit message (below). That behavior might make sense to make the http and https modules more usable, but in the setting of an HTTP proxy, fidelity is much more important.

This seems possible via the useChunkedEncodingByDefault attribute, but that is undocumented and likely unstable. I wasn't able to get it working locally, likely because this library uses pipe for all "incoming" requests. When piping data, the useChunkedEncodingByDefault flag does not seem to be honored. This probably makes sense because a streaming interface would generally emit data in chunks... so maybe special-casing HTTP verbs is the best approach, after all.

Commit message:

Web browsers automatically issue an OPTIONS request in advance of other HTTP requests when the document's domain does not match the target in order to facilitate Cross-Origin Resource Sharing. These requests are forbidden from specifying a body and typically do not specify an (unecessary) Length header.

Node.js automatically adds the Content-Encoding: chunked header value to requests that do not specify a Length header. This makes proxied OPTIONS requests from web browsers invalid.

Explicitly set the Content-Length header of all OPTIONS requests to "0", disabling the default "chunked" encoding behavior [2].

[1] http://www.w3.org/TR/cors/ [2] http://nodejs.org/api/http.html

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/jugglinmike/option-content-length