diff options
| author | Brad Fitzpatrick <bradfitz@golang.org> | 2015-12-09 22:02:46 +0000 |
|---|---|---|
| committer | Brad Fitzpatrick <bradfitz@golang.org> | 2015-12-10 04:43:08 +0000 |
| commit | c2ef005486fa05cbeddc74c7faac8f6a867703d4 (patch) | |
| tree | c96bea2c128d9f61b8e359ab3fed1ccc14eca59b /src/net/http/fs_test.go | |
| parent | 07f9c25b357d2eb1305e5016a967df1b00d345bd (diff) | |
| download | go-c2ef005486fa05cbeddc74c7faac8f6a867703d4.tar.xz | |
net/http: run more tests in http2 mode
Failing ones are marked skipped.
Fixes #13543 (was just a test issue)
Updates #13555 (to be fixed later)
Updates #13556 (to be fixed later)
Updates #13557 (to be fixed later)
Fixes bug in golang.org/cl/17428 (http1 now uses HTTP status 431, not 413)
Change-Id: I8f7431fee35f2fc081cfe2c232ae75a00800a60b
Reviewed-on: https://go-review.googlesource.com/17683
Reviewed-by: Blake Mizerany <blake.mizerany@gmail.com>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Reviewed-by: Burcu Dogan <jbd@google.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/net/http/fs_test.go')
| -rw-r--r-- | src/net/http/fs_test.go | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/src/net/http/fs_test.go b/src/net/http/fs_test.go index 7550c552d1..2e17d3f4bb 100644 --- a/src/net/http/fs_test.go +++ b/src/net/http/fs_test.go @@ -477,14 +477,27 @@ func TestServeFileFromCWD(t *testing.T) { } } -func TestServeFileWithContentEncoding(t *testing.T) { +// Tests that ServeFile doesn't add a Content-Length if a Content-Encoding is +// specified. +func TestServeFileWithContentEncoding_h1(t *testing.T) { testServeFileWithContentEncoding(t, h1Mode) } +func TestServeFileWithContentEncoding_h2(t *testing.T) { testServeFileWithContentEncoding(t, h2Mode) } +func testServeFileWithContentEncoding(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().Set("Content-Encoding", "foo") ServeFile(w, r, "testdata/file") + + // Because the testdata is so small, it would fit in + // both the h1 and h2 Server's write buffers. For h1, + // sendfile is used, though, forcing a header flush at + // the io.Copy. http2 doesn't do a header flush so + // buffers all 11 bytes and then adds its own + // Content-Length. To prevent the Server's + // Content-Length and test ServeFile only, flush here. + w.(Flusher).Flush() })) - defer ts.Close() - resp, err := Get(ts.URL) + defer cst.close() + resp, err := cst.c.Get(cst.ts.URL) if err != nil { t.Fatal(err) } |
