diff options
-rw-r--r-- | modules/caddyhttp/server.go | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/modules/caddyhttp/server.go b/modules/caddyhttp/server.go index 4f198e5df..aaec711c4 100644 --- a/modules/caddyhttp/server.go +++ b/modules/caddyhttp/server.go @@ -209,6 +209,14 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) { 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 logger := errLog if s.Logs != nil { |