Skip to content

Commit

Permalink
[internal-branch.go1.17-vendor] http2: deflake TestTransportReqBodyAf…
Browse files Browse the repository at this point in the history
…terResponse_200

Don't send the END_STREAM flag from the server until the client
sends its END_STREAM. Avoids a flaky failure when the client
sends the END_STREAM in a zero-length DATA frame:

  - The server reads bodySize bytes and half-closes the stream.
  - The client's Response.Body returns EOF.
  - The test calls Response.Body.Close.
  - The client resets the stream.

Avoid hanging forever on the client side of the test if the
server side exits with an error.

Updates golang/go#49077

Change-Id: Ic921a3f60149abbb5434ec7a53985becea7b23c3
Reviewed-on: https://go-review.googlesource.com/c/net/+/355649
Trust: Damien Neil <dneil@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-on: https://go-review.googlesource.com/c/net/+/357691
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
  • Loading branch information
neild authored and dmitshur committed Oct 29, 2021
1 parent d714dec commit 875be97
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion transport_test.go
Expand Up @@ -934,6 +934,7 @@ func testTransportReqBodyAfterResponse(t *testing.T, status int) {
}
ct.server = func() error {
ct.greet()
defer close(recvLen)
var buf bytes.Buffer
enc := hpack.NewEncoder(&buf)
var dataRecv int64
Expand Down Expand Up @@ -984,7 +985,7 @@ func testTransportReqBodyAfterResponse(t *testing.T, status int) {
dataRecv += int64(dataLen)

if !closed && ((status != 200 && dataRecv > 0) ||
(status == 200 && dataRecv == bodySize)) {
(status == 200 && f.StreamEnded())) {
closed = true
if err := ct.fr.WriteData(f.StreamID, true, nil); err != nil {
return err
Expand Down

0 comments on commit 875be97

Please sign in to comment.