-
Notifications
You must be signed in to change notification settings - Fork 17.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
net/http: allow control of case of header key #5022
Comments
This is the first report I've seen in 2+ years of issues with this design. It's impractical to change at this point. Maybe we could provide some way for you to white-list certain header keys, or to provide your own WriteRequest function to the Transport. But that will have to wait until after Go 1.1. Labels changed: removed priority-triage. Status changed to Thinking. |
Re: #4, indeed. I forgot that worked. (I thought WriteHeader did the canonicalization) I added a test in https://golang.org/cl/7712043 to verify we don't break that going forward. Then I'll close this. Owner changed to @bradfitz. Status changed to Started. |
This issue was closed by revision f0396ca. Status changed to Fixed. |
Comment 7 by tyson@stovepipestudios.com: Works for me -- thanks! |
Comment 8 by dan@ezoic.com: Example where case is important: In mod_pagespeed, the header "PageSpeed" to enable or disable the module for a specific request, is case sensitive. Two google products not working nicely together. :) In a broader way, if the app is acting like a proxy and the headers are not used directly by the app but rather passed thru to two other http servers, it may matter. |
@bradfitz This also happens when you write a response Header from the server side perspective. Here's an example: http://play.golang.org/p/o37Js5lb8f Are you planning to make this change also for response headers?. Should I open another issue? Thanks |
this issue has been closed, please file a new one. Thanks. |
It's closed but I'll reply again for the record, to unify conversations that have happened in several places: We won't be changing this. HTTP/2 doesn't even have case in headers. If you have an application that cares, it's broken, has always been broken, and needs to be fixed sooner than later. |
Perfect @bradfitz. I do also agree with you that applications should comply with the specs, but as you know that usually doesn't happen 😄. Thanks for the response. |
I have an http server application reading header like this:
In |
Now I have to change my code everywhere to be like this in order to be compatible with old versions: apiTokenId := r.Header.Get("api_token_id")
if apiTokenId == "" {
apiTokenId = r.Header.Get("Api_token_id")
} I don't understand why the library should manipulate the header key, as if I don't know what I am doing. |
@elgs just wrap your |
@marcosnils thanks, but I don't understand what you meant by wrapping my |
Because Header.Get already handles CanonicalHeaderKey
transformations for you.
This issue has already been closed for some time, please
ask questions elsewhere (see https://golang.org/wiki/Questions)
|
@minux I don't mind talking a bit more here as here is the perfect context for this question. I think |
HTTP headers are case insensitive, and net/http.Header is a map,
so there has to be a canonical case mapping somewhere. And
Header.Get already handles all these for you.
We don't do discussions on closed issues, so please ask questions
on the mailing list. Thanks.
|
Aha! OK, that makes sense to me. Thanks @minux. |
by tyson@stovepipestudios.com:
The text was updated successfully, but these errors were encountered: