Skip to content

Commit

Permalink
[internal-branch.go1.17-vendor] http2: remove check for read-after-cl…
Browse files Browse the repository at this point in the history
…ose of request bodies

Aborting a request currently races with writes of the request
body, so abortRequestBodyWrite can close the body before writeRequestBody
reads from it.

Updates golang/go#49077

Change-Id: I5362283f4066611aeecbc48b400d79cfa0b4b284
Reviewed-on: https://go-review.googlesource.com/c/net/+/351972
Trust: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-on: https://go-review.googlesource.com/c/net/+/357679
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
  • Loading branch information
neild authored and dmitshur committed Oct 29, 2021
1 parent 6c65466 commit 2e3989c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion transport_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4969,7 +4969,10 @@ func (rc *closeChecker) Read(b []byte) (n int, err error) {
select {
default:
case <-rc.closed:
panic("read from closed body")
// TODO(dneil): Consider restructuring the request write to avoid reading
// from the request body after closing it, and check for read-after-close here.
// Currently, abortRequestBodyWrite races with writeRequestBody.
return 0, errors.New("read after Body.Close")
}
return rc.ReadCloser.Read(b)
}
Expand Down

0 comments on commit 2e3989c

Please sign in to comment.