Skip to content
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: Request.ReadRequest() should not delete Request.Header["Host"] #13134

yamada95 opened this issue Nov 3, 2015 · 1 comment


Copy link

@yamada95 yamada95 commented Nov 3, 2015

I think Request.Header["Host"] should not be deleted when parsing the request.

For example, if I use the net/http to write a proxy server, listening on, and issue the following command:
curl --proxy "" -H "Host:" ""

The proxy should deliver the Host header to origin server, but it's already deleted by Request.ReadRequest() when reading request from client( In this case, if the origin server is configured as a nginx virtual server server_name, it will return 404 because of mismatching host name.


This comment has been minimized.

Copy link

@bradfitz bradfitz commented Nov 3, 2015

The Host header is put into the Request.Host field:

It's been like that for ages. Changing it now, regardless of whether it's a good idea, would be a incompatible change.

In any case, you seem to have a concrete problem about writing a proxy. Let's discuss that instead on one of the forums:

@bradfitz bradfitz closed this Nov 3, 2015
@golang golang locked and limited conversation to collaborators Nov 4, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.