mirror of
https://github.com/golang/go.git
synced 2025-05-29 03:11:26 +00:00
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: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
10d1d5b673
commit
1092257f7e
@ -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)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user