-
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: requests seem to ignore Host headers? #29865
Comments
Set the |
Line 92 in cad6d1f
|
Set the Host field in https://golang.org/pkg/net/http/#Request to override the host value in the URL. |
What @agnivade said: https://play.golang.org/p/4W_KJGBa77s It works. |
What version of Go are you using (
go version
)?go1.8.1 linux/amd64
What did you do?
net/http requests seem to ignore Host headers?
`package main
import "os"
import "net/http"
func main() {
req, _ := http.NewRequest("GET", "http://1.2.3.4", nil)
// I wish explicitly setting this Host header would take precedence
req.Header.Set("Host", "www.example.org")
req.Write(os.Stdout)
}
`
What did you expect to see?
I want to send to the stable nginx host, but not change the host header which different from the nginx host.
What did you see instead?
Example output:
GET / HTTP/1.1
Host: 1.2.3.4
User-Agent: Go http package
Before I go further, am I doing this correctly?
The text was updated successfully, but these errors were encountered: