net/http: Post redirect can submit entity body when redirecting with GET request #57273
Labels
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
As discussed in #52519, it's possible for the
http.Client
to perform an invalid request when it receives a redirect status code which changes the request method from POST to GET, removing the entity body without updating the required headers.See rack/rack#1994 for more context.
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
The problem is explained in https://github.com/ioquatix/rack-go-http-client-redirect-bug with a reproduction.
What did you expect to see?
I expected it to follow the similar model as the fetch specification for handling redirects: https://fetch.spec.whatwg.org/#http-redirect-fetch.
Specifically, when receiving a redirect which causes the request method to change to
GET
, it needs to remove the entity body and the following headers:content-encoding
content-language
content-location
content-type
What did you see instead?
A GET request which includes a
content-type
header without an entity body (invalid).The text was updated successfully, but these errors were encountered: