Skip to content

net/http: upon http redirect, Request.GetBody is always nil #73439

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

Open
maruel opened this issue Apr 18, 2025 · 4 comments
Open

net/http: upon http redirect, Request.GetBody is always nil #73439

maruel opened this issue Apr 18, 2025 · 4 comments
Labels
BugReport Issues describing a possible bug in the Go implementation. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.

Comments

@maruel
Copy link
Contributor

maruel commented Apr 18, 2025

Go version

go version devel go1.25-252c939445 Fri Apr 18 08:30:30 2025 -0700 linux/amd64

Output of go env in your module/workspace:

AR='ar'
CC='gcc'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='g++'
GCCGO='gccgo'
GO111MODULE=''
GOAMD64='v1'
GOARCH='amd64'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/home/maruel/.cache/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/home/maruel/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build432130765=/tmp/go-build -gno-record-gcc-switches'
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMOD='/home/maruel/src-oth/golang/src/go.mod'
GOMODCACHE='/home/maruel/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/maruel/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/home/maruel/src-oth/golang'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/home/maruel/.config/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/home/maruel/src-oth/golang/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='devel go1.25-252c939445 Fri Apr 18 08:30:30 2025 -0700'
GOWORK=''
PKG_CONFIG='pkg-config'

What did you do?

Implement a http.RoundTripper that leverages http.Request.GetBody. Handle a server that returns 307/308 on a POST.

What did you see happen?

http.Request.GetBody is always nil after a HTTP redirect.

What did you expect to see?

http.Request.GetBody is copied over so the RoundTripper can rewind the request body if needed.

@maruel
Copy link
Contributor Author

maruel commented Apr 18, 2025

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/666735 mentions this issue: net/http: upon http redirect, copy Request.GetBody in new request

@gabyhelp gabyhelp added the BugReport Issues describing a possible bug in the Go implementation. label Apr 18, 2025
@JunyangShao
Copy link
Contributor

@neild

@JunyangShao JunyangShao added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Apr 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BugReport Issues describing a possible bug in the Go implementation. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants