-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Provide access to original http headers (not lowercased) #4844
Comments
Hi there, If I understand you correct, you only want the raw headers on the incoming request right? |
outgoing request headers dont get lowercased so there is no separation between raw and "normalized" headers in that case. |
I haven't checked with master, but that doesnt happen with v0.8. See this test and this discussion. |
Indeed, I see the outgoing header names are not lowercased. |
@stiang I have added functionality that would allow you to use the mixed case form of your http header keys. Please see: newtondev/node@ddc0070 Is this the kind of functionality you were looking for? I hope someone would find it useful. |
FYI: The HTTP/1.1 spec states "Field names are case-insensitive." (http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html) |
@newtondev Sorry for the late reply, I got sidetracked and completely forgot about this. As far as I can tell your code looks like it would solve my issue, but according to @isaacs there is little interest in changing req.headers, only in providing access to raw headers in addition to the lowercased headers. So your patch might not get approved. @skenqbx Yes, node.js handles headers correctly according to the spec, but that’s not the issue. Some buggy systems incorrectly treat headers with different case differently, and it is sometimes useful to retain the original "casing" (is there a word for that?) when building systems which interact with such buggy systems - especially for a proxy service like the one I described in the issue, which is designed presicely to debug HTTP protocol issues. |
+1 about buggy clients. I would like to have access to original header names as well. |
I am super interested in this feature. I am running node as a proxy in front of some legacy applications and my developers didn't follow the spec so they depend on having the headers keep their case. I have gotten some of the applications fixed but it is a tiring exercise. I am happy to help implement this if it isn't already being worked on. Please let me know. |
I'm currently working on changing how http headera are processed for This is for master, and won't be back ported to v0.10. I'm not sure a PR |
All I need is for the unaltered headers to be accessible in another variable and I am happy. I can wait for your updates if this is something that has the chance of making it in. I would rather not maintain my own code. If you decide not to add this I would be happy to work on a patch. |
Please see my fork for the fix for this issue: https://github.com/newtondev/node Please see the notes for the last commit that explains how to obtain the raw headers. Hope this helps you :) Here is the diff and notes: newtondev/node@ddc0070 |
newtondev, this will do what I need. I'd still like to see it in the main master branch. :) |
@grudzien thanks, I would also like to see it in the main master branch, unfortunately there is only a few people interested in the functionality. The reason being is that all headers should be lowercased and is the standard, this is just a workaround for servers that do not conform to the standard. |
This will not be done in stable. It is an option for master. A global switch on the http module is not a good api for this, though. We ought to just stash the raw header values on a separate key. It's not that much data. |
I am good with having the raw headers available and it would be nice if I could substitute them in my proxy code so that my users only see them. This will ensure that my legacy apps will function. |
Opening a new issue as requested in #1954 (comment).
It is sometimes necessary to have access to the raw http headers, before they have been lowercased. A real-world use-case is a proxy service that provides web access to headers and bodies sent over the wire, typically used when debugging/testing APIs.
Header case can matter when dealing with buggy clients or upstream servers, so for such a service to be as useful as possible it needs to display the original headers.
The solution proposed is to keep req/resp.headers lowercased, like today, but add an additional object/string, like req.rawHeaders, for those who need it.
The text was updated successfully, but these errors were encountered: