Commit 1092257f authored by Emmanuel Odeke's avatar Emmanuel Odeke Committed by Brad Fitzpatrick

net/http: zeroLengthPostAndResponse test now in http2 mode

Change-Id: I282a399657c71f7b6406fcdde8afc82a13bdfe5f
Reviewed-on: https://go-review.googlesource.com/17530
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
parent 10d1d5b6
......@@ -1825,9 +1825,16 @@ func TestRedirectBadPath(t *testing.T) {
// connection immediately. But when it re-uses the connection, it typically closes
// the previous request's body, which is not optimal for zero-lengthed bodies,
// as the client would then see http.ErrBodyReadAfterClose and not 0, io.EOF.
func TestZeroLengthPostAndResponse(t *testing.T) {
func TestZeroLengthPostAndResponse_h1(t *testing.T) {
testZeroLengthPostAndResponse(t, false)
}
func TestZeroLengthPostAndResponse_h2(t *testing.T) {
testZeroLengthPostAndResponse(t, true)
}
func testZeroLengthPostAndResponse(t *testing.T, h2 bool) {
defer afterTest(t)
ts := httptest.NewServer(HandlerFunc(func(rw ResponseWriter, r *Request) {
cst := newClientServerTest(t, h2, HandlerFunc(func(rw ResponseWriter, r *Request) {
all, err := ioutil.ReadAll(r.Body)
if err != nil {
t.Fatalf("handler ReadAll: %v", err)
......@@ -1837,9 +1844,9 @@ func TestZeroLengthPostAndResponse(t *testing.T) {
}
rw.Header().Set("Content-Length", "0")
}))
defer ts.Close()
defer cst.close()
req, err := NewRequest("POST", ts.URL, strings.NewReader(""))
req, err := NewRequest("POST", cst.ts.URL, strings.NewReader(""))
if err != nil {
t.Fatal(err)
}
......@@ -1847,7 +1854,7 @@ func TestZeroLengthPostAndResponse(t *testing.T) {
var resp [5]*Response
for i := range resp {
resp[i], err = DefaultClient.Do(req)
resp[i], err = cst.c.Do(req)
if err != nil {
t.Fatalf("client post #%d: %v", i, 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