Browse Source

caddyhttp: Restore original request params before error handlers (#3781)

* caddyhttp: Restore original request params before error handlers

Fixes #3717

* Add comment
master
Matt Holt 4 years ago
committed by GitHub
parent
commit
385adf5d87
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      modules/caddyhttp/server.go

8
modules/caddyhttp/server.go

@ -209,6 +209,14 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
return return
} }
// restore original request before invoking error handler chain (issue #3717)
// TODO: this does not restore original headers, if modified (for efficiency)
origReq := r.Context().Value(OriginalRequestCtxKey).(http.Request)
r.Method = origReq.Method
r.RemoteAddr = origReq.RemoteAddr
r.RequestURI = origReq.RequestURI
cloneURL(origReq.URL, r.URL)
// prepare the error log // prepare the error log
logger := errLog logger := errLog
if s.Logs != nil { if s.Logs != nil {

Loading…
Cancel
Save