net/http/httputil: make it easier for ReverseProxy.ErrorHandler to preserve the request body #33726
Labels
FeatureRequest
Issues asking for a new feature that does not need a proposal.
FrozenDueToAge
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
What version of Go are you using (
go version
)?We could use
ErrorHandler func(http.ResponseWriter, *http.Request, error)
to handle errors when backend timeout, but one important fact is theBody io.ReadCloser
in http.Request of ErrorHandler func is no "readable", because the interface io.ReadClose
just like a stream, you could not read twice from it.
So when I add some "retry function" in the ErrorHandler, the Body always empty, we could
not retry this request to another health backend, to let my project work I do something like
this in
func (p *ReverseProxy) ServeHTTP(rw http.ResponseWriter, req *http.Request):
Maybe we have 2 options:
The text was updated successfully, but these errors were encountered: