diff options
author | Matt Holt <[email protected]> | 2020-10-13 10:52:39 -0600 |
---|---|---|
committer | GitHub <[email protected]> | 2020-10-13 10:52:39 -0600 |
commit | 385adf5d878939c381c7f73c771771d34523a1a7 (patch) | |
tree | 2516e1b6d19d928afcf45ef8fc111a60cd9684e6 | |
parent | c7efb0307d425eb533885e314518c370a06763da (diff) | |
download | caddy-2.2.3.tar.gz caddy-2.2.3.zip |
* caddyhttp: Restore original request params before error handlers
Fixes #3717
* Add comment
-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 { |