Skip to content

net/http: Request.ReadRequest() should not delete Request.Header["Host"]  #13134

Closed
@yamada95

Description

@yamada95

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 127.0.0.1:8080, and issue the following command:
curl --proxy "127.0.0.1:8080" -H "Host: domain.com" "http://130.130.10.10/ping"

The proxy should deliver the Host header to origin server 130.130.10.10, but it's already deleted by Request.ReadRequest() when reading request from client(https://golang.org/src/net/http/request.go?h=http#L714). In this case, if the origin server is configured as a nginx virtual server server_name domain.com, it will return 404 because of mismatching host name.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions