mirror of https://github.com/golang/go.git
net/http: sniffWrite test also in http2 mode
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>
This commit is contained in:
parent
c34bc90ffc
commit
3d70475833
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue