Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/net/http2: RoundTrip does not close request body after early errors #48341

Closed
neild opened this issue Sep 12, 2021 · 1 comment
Closed

x/net/http2: RoundTrip does not close request body after early errors #48341

neild opened this issue Sep 12, 2021 · 1 comment
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@neild
Copy link
Contributor

neild commented Sep 12, 2021

The RoundTrip contract states that the request body should be closed by RoundTrip, even when an error occurs.

The HTTP/2 RoundTrip does not close the request body in various situations:

  • If the request is invalid: transport.go#1011 and in subsequent failures early in request processing.
  • If an open slot cannot be acquired on the selected ClientConn: transport.go#1026
  • If a new request body is acquired from GetBody: transport.go#550 (While the exact handling of bodies created by GetBody is not fully documented, the HTTP/1 RoundTrip implementation closes both the original Request.Body and every body returned by Request.GetBody.)
@cagedmantis cagedmantis added this to the Unreleased milestone Sep 13, 2021
@cagedmantis cagedmantis added the NeedsFix The path to resolution is known, but the work has not been done. label Sep 13, 2021
@gopherbot
Copy link

Change https://golang.org/cl/349489 mentions this issue: http2: close request body after early RoundTrip failures

dteh pushed a commit to dteh/fhttp that referenced this issue Jun 22, 2022
The RoundTrip contract requires that the request Body be closed,
even when an error occurs sending the request.

Fix several cases where the body was not closed by hoisting the
Close call to Transport.RoundTripOpt. Now ClientConn.roundTrip
takes responsibility for closing the body once the body write
begins; otherwise, the caller does so.

Fix the case where a new body is acquired via Request.GetBody
to close the previous body, matching net/http's behavior.

Fixes golang/go#48341.

Change-Id: Id9dc682d4d86a1c255c7c0d864208ff76ed53eb2
Reviewed-on: https://go-review.googlesource.com/c/net/+/349489
Trust: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
@golang golang locked and limited conversation to collaborators Sep 13, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

3 participants