Skip to content

net/http/httputil: ReverseProxyHeader doesn't preserve header key case #18196

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

Closed
JasonGLYao opened this issue Dec 5, 2016 · 3 comments
Closed

Comments

@JasonGLYao
Copy link

JasonGLYao commented Dec 5, 2016

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

1.7

What operating system and processor architecture are you using (go env)?

Windows 7 & Intel Core I5(x64)

What did you do?

If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.

  1. A Client program written in C# which will post HTTP request to the server side with additional customized header key(eg: HostName)
  2. A proxy written in Go which acting the role of proxy ,after this action , the header key will be change to canonicalMIME style(Hostname).
  3. Server side program will try to fetch the header info, while use the key(HostName)to get its value, empty value got.
  4. How to process the Standard Key word of "TE" in GoLang?

What did you expect to see?

HostName -->HostName in httprequest header while using the ReverseProxy functions

/proxy := httputil.NewSingleHostReverseProxy(remote)
proxy.ServeHTTP(w, r)
/

What did you see instead?

HostName -->Hostname in httprequest header while using the ReverseProxy functions

https://en.wikipedia.org/wiki/List_of_HTTP_header_fields

@bradfitz
Copy link
Contributor

bradfitz commented Dec 5, 2016

Sorry, HTTP headers are case insensitive.

Your backend sounds buggy.

I'm not sure this is worth "fixing" in Go because it would be very invasive at many levels.

@bradfitz bradfitz changed the title NewSingleHostReverseProxy--Header Key Formatting Issue net/http/httputil: ReverseProxyHeader doesn't preserve header key case Dec 5, 2016
@bradfitz bradfitz added this to the Unplanned milestone Dec 5, 2016
@JasonGLYao
Copy link
Author

Thanks for reply.

@bradfitz
Copy link
Contributor

bradfitz commented Feb 1, 2017

I thought about this more and still think the change would be way too invasive to be worth supporting broken application. Considering that http2 doesn't preserve the case of headers either, and http2 is becoming increasingly prevalent, people will need to fix their buggy assumptions sooner or later anyway.

Sorry, closing.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants