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: setting Content-Type header to []string{""} in http handler causes two Content-Type headers to be emitted #5953
Comments
This happens because we're cutting corners testing for the presence of the header. Labels changed: added priority-later, removed priority-triage. Owner changed to @bradfitz. Status changed to Accepted. |
https://golang.org/cl/12117043 Status changed to Started. |
This issue was closed by revision 252c107. Status changed to Fixed. |
This issue was closed by revision 21e6b90. |
This issue seems to persist for http2 please see CL https://go-review.googlesource.com/17462 that uncovered it commit eec4d694e3ed2fcc91d72f82c9a2c37c7d17f5c2
Author: Emmanuel Odeke <emm.odeke@gmail.com>
Date: Fri Dec 4 17:21:08 2015 -0700
net/http: sniffTest for 5953 set in http2 mode
Change-Id: I345b6ea7024a1c85c805b2d2e22f9f79aeca5816
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 |
cc @bradfitz |
@odeke-em, please open a new bug and reference this one. Once bugs are closed, we no longer use them. |
Aye aye, thanks for that. I'll do that right now. |
The text was updated successfully, but these errors were encountered: