diff options
author | Matt Holt <mholt@users.noreply.github.com> | 2020-10-13 10:52:39 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-13 10:52:39 -0600 |
commit | 385adf5d878939c381c7f73c771771d34523a1a7 (patch) | |
tree | 2516e1b6d19d928afcf45ef8fc111a60cd9684e6 /modules | |
parent | c7efb0307d425eb533885e314518c370a06763da (diff) |
caddyhttp: Restore original request params before error handlers (#3781)
* caddyhttp: Restore original request params before error handlers
Fixes #3717
* Add comment
Diffstat (limited to 'modules')
-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 4f198e5..aaec711 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 { |