You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
diff --git a/src/net/http/sniff_test.go b/src/net/http/sniff_test.go
index 293a7f5..a372210 100644
--- a/src/net/http/sniff_test.go+++ b/src/net/http/sniff_test.go@@ -88,15 +88,18 @@ func testServerContentType(t *testing.T, h2 bool) {
// Issue 5953: shouldn't sniff if the handler set a Content-Type header,
// even if it's the empty string.
-func TestServerIssue5953(t *testing.T) {+func TestServerIssue5953_h1(t *testing.T) { testServerIssue5953(t, false) }+func TestServerIssue5953_h2(t *testing.T) { testServerIssue5953(t, true) }++func testServerIssue5953(t *testing.T, h2 bool) {
defer afterTest(t)
- ts := httptest.NewServer(HandlerFunc(func(w ResponseWriter, r *Request) {+ cst := newClientServerTest(t, h2, HandlerFunc(func(w ResponseWriter, r *Request) {
w.Header()["Content-Type"] = []string{""}
fmt.Fprintf(w, "<html><head></head><body>hi</body></html>")
}))
- defer ts.Close()+ defer cst.close()- resp, err := Get(ts.URL)+ resp, err := cst.c.Get(cst.ts.URL)
if err != nil {
t.Fatal(err)
}
$ go test --cover
--- FAIL: TestServerIssue5953_h2 (0.00s)
sniff_test.go:110: Content-Type = ["""text/html; charset=utf-8"]; want [""]
FAIL
coverage: 77.4% of statements
exit status 1
FAIL net/http 22.409s
The text was updated successfully, but these errors were encountered:
mikioh
changed the title
net/http2: setting Content-Type header to []string{""} in http handler causes two Content-Type headers to be emitted
net/http: setting Content-Type header to []string{""} in http handler causes two Content-Type headers to be emitted
Dec 8, 2015
* don't send automatic Content-Length from Server on HEAD requests if
response size is 0 (it's possible the handler didn't write because
they looked at the method)
* don't send Content-Type if handler explicitly set it to nothing.
Matches the behavior of HTTP/1.
Updates golang/go#13532
Updates golang/go#13495
Change-Id: If6e0898095cf88cb14efb6bbe82c88dbc2077e6b
Reviewed-on: https://go-review.googlesource.com/17590
Reviewed-by: Blake Mizerany <[email protected]>
This issue is a followup of #5953 which was noticed during a port of tests to http2 in CL https://go-review.googlesource.com/#/c/17462/ or in code
The text was updated successfully, but these errors were encountered: