Commit 3d704758 authored by Emmanuel Odeke's avatar Emmanuel Odeke Committed by Brad Fitzpatrick

net/http: sniffWrite test also in http2 mode

Change-Id: Ifa9f1ed6a3b8d3f7536f2d315259940335b0ee49
Reviewed-on: https://go-review.googlesource.com/17438Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent c34bc90f
......@@ -146,9 +146,12 @@ func testContentTypeWithCopy(t *testing.T, h2 bool) {
resp.Body.Close()
}
func TestSniffWriteSize(t *testing.T) {
func TestSniffWriteSize_h1(t *testing.T) { testSniffWriteSize(t, false) }
func TestSniffWriteSize_h2(t *testing.T) { testSniffWriteSize(t, true) }
func testSniffWriteSize(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) {
size, _ := strconv.Atoi(r.FormValue("size"))
written, err := io.WriteString(w, strings.Repeat("a", size))
if err != nil {
......@@ -159,9 +162,9 @@ func TestSniffWriteSize(t *testing.T) {
t.Errorf("write of %d bytes wrote %d bytes", size, written)
}
}))
defer ts.Close()
defer cst.close()
for _, size := range []int{0, 1, 200, 600, 999, 1000, 1023, 1024, 512 << 10, 1 << 20} {
res, err := Get(fmt.Sprintf("%s/?size=%d", ts.URL, size))
res, err := cst.c.Get(fmt.Sprintf("%s/?size=%d", cst.ts.URL, size))
if err != nil {
t.Fatalf("size %d: %v", size, err)
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment