Commit cd566958 authored by Brad Fitzpatrick's avatar Brad Fitzpatrick

net/http: test that we preserve Go 1.0 Request.Write Host behavior

Fixes #4792

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7314093
parent 594360cb
...@@ -328,6 +328,31 @@ var reqWriteTests = []reqWriteTest{ ...@@ -328,6 +328,31 @@ var reqWriteTests = []reqWriteTest{
"User-Agent: Go http package\r\n" + "User-Agent: Go http package\r\n" +
"X-Foo: X-Bar\r\n\r\n", "X-Foo: X-Bar\r\n\r\n",
}, },
// If no Request.Host and no Request.URL.Host, we send
// an empty Host header, and don't use
// Request.Header["Host"]. This is just testing that
// we don't change Go 1.0 behavior.
{
Req: Request{
Method: "GET",
Host: "",
URL: &url.URL{
Scheme: "http",
Host: "",
Path: "/search",
},
ProtoMajor: 1,
ProtoMinor: 1,
Header: Header{
"Host": []string{"bad.example.com"},
},
},
WantWrite: "GET /search HTTP/1.1\r\n" +
"Host: \r\n" +
"User-Agent: Go http package\r\n\r\n",
},
} }
func TestRequestWrite(t *testing.T) { func TestRequestWrite(t *testing.T) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment