Closed
Description
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
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