author | Brad Fitzpatrick
<bradfitz@golang.org> 2016-07-13 17:36:29 UTC |
committer | Brad Fitzpatrick
<bradfitz@golang.org> 2016-07-13 19:45:06 UTC |
parent | f841c39de738b1d0df95b5a7187744f0e03d8112 |
http2/transport_test.go | +11 | -9 |
diff --git a/http2/transport_test.go b/http2/transport_test.go index 39abde2..ec7d7e0 100644 --- a/http2/transport_test.go +++ b/http2/transport_test.go @@ -755,18 +755,18 @@ func testTransportReqBodyAfterResponse(t *testing.T, status int) { if f.StreamEnded() { return fmt.Errorf("headers contains END_STREAM unexpectedly: %v", f) } - time.Sleep(50 * time.Millisecond) // let client send body - enc.WriteField(hpack.HeaderField{Name: ":status", Value: strconv.Itoa(status)}) - ct.fr.WriteHeaders(HeadersFrameParam{ - StreamID: f.StreamID, - EndHeaders: true, - EndStream: false, - BlockFragment: buf.Bytes(), - }) case *DataFrame: dataLen := len(f.Data()) - dataRecv += int64(dataLen) if dataLen > 0 { + if dataRecv == 0 { + enc.WriteField(hpack.HeaderField{Name: ":status", Value: strconv.Itoa(status)}) + ct.fr.WriteHeaders(HeadersFrameParam{ + StreamID: f.StreamID, + EndHeaders: true, + EndStream: false, + BlockFragment: buf.Bytes(), + }) + } if err := ct.fr.WriteWindowUpdate(0, uint32(dataLen)); err != nil { return err } @@ -774,6 +774,8 @@ func testTransportReqBodyAfterResponse(t *testing.T, status int) { return err } } + dataRecv += int64(dataLen) + if !closed && ((status != 200 && dataRecv > 0) || (status == 200 && dataRecv == bodySize)) { closed = true