]> Cypherpunks repositories - gostls13.git/commitdiff
net/http: sniffWrite test also in http2 mode
authorEmmanuel Odeke <emm.odeke@gmail.com>
Sat, 5 Dec 2015 06:22:26 +0000 (23:22 -0700)
committerBrad Fitzpatrick <bradfitz@golang.org>
Mon, 7 Dec 2015 15:50:34 +0000 (15:50 +0000)
Change-Id: Ifa9f1ed6a3b8d3f7536f2d315259940335b0ee49
Reviewed-on: https://go-review.googlesource.com/17438
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/net/http/sniff_test.go

index 293a7f52d06a819f04e5d4a3f05b4a9d22dc0dfd..170de7314c47239e9dfae5cd1cd284d0fef6e9dd 100644 (file)
@@ -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)
                }