node-http-proxy
node-http-proxy copied to clipboard
Preserve header case for incoming requests.
#1107
I'm welcome this PR, because I didn't care about incoming request. But I'm not a maintainer, please take their review ;)
IMO, Existing specs seems not to cover additional behavior. Would you please add specs?
I think we've just bumped into some problems related to this. Is there a way we can help to get this merged and released?
It's worth to mention that the http message spec describes headers as a case insensitive. Therefore clients/servers that relays on headers cases sensitivity are not complying with the spec and should not be expected to work properly. Developers shouldn't get used to bad practices (especially if something is against the spec) and therefore this PR shouldn't be accepted. That's only my opinion.
@jarrodek The issue here is dealing with 3rd party software or legacy software that does not adhere to the spec and we have no control over.
The same with us. I think node-http-proxy preserving case of header names would be something similar to "be benevolent in what you accept and strict about what you produce". I totally agree it's ridiculous some software is HTTP header name case-sensitive, but software is made by humans and humans make mistakes.
This is very simple change node-http-proxy can do and it even actually makes sort of sense - IMHO the proxy should pass things "as is" to be as unnoticeable as possible, unless it really needs to touch them and modify them for some purpose.
I totally agree with @honzajavorek The proxy should be totally transparent for passing data and not alter them. In this case, however, it doesn't actually changes the data. If anything, that's the problem of Node's Request object and not the proxy. This PR actually introduce a behavior where data are altered by the proxy. This PR should be sent to Node because that's the source of the problem and not this module.
Just ran into this problem where for whatever reason the service I'm calling expects a header to be Mixed Case ('X-HTTP-Method-Override'). Even with the preserveHeaderKeyCase: true
it looks like the header is being rewritten to ('x-http-method-override'). I'm able to work around this by rewriting the headers... but it's a pretty lame solution since I'd have to do it for each header and I may not now what the original case was. Why wouldn't it just leave the header casing alone in the first place??
const onProxyReq = (proxyReq, req) => {
if (req.headers['x-http-method-override']) {
proxyReq.setHeader('X-HTTP-Method-Override', req.headers['x-http-method-override']);
}
};
Just ran into this same issue as @mrichmond described... Why are headers rewritten to lower-case?