Skip to content

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

@maruel

Description

@maruel

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugReportIssues describing a possible bug in the Go implementation.NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions