mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
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>
This commit is contained in:
parent
07f9c25b35
commit
c2ef005486
7 changed files with 144 additions and 105 deletions
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue