summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMatt Holt <[email protected]>2020-10-13 10:52:39 -0600
committerGitHub <[email protected]>2020-10-13 10:52:39 -0600
commit385adf5d878939c381c7f73c771771d34523a1a7 (patch)
tree2516e1b6d19d928afcf45ef8fc111a60cd9684e6
parentc7efb0307d425eb533885e314518c370a06763da (diff)
downloadcaddy-385adf5d878939c381c7f73c771771d34523a1a7.tar.gz
caddy-385adf5d878939c381c7f73c771771d34523a1a7.zip
caddyhttp: Restore original request params before error handlers (#3781)v2.2.3v2.2.1
* caddyhttp: Restore original request params before error handlers Fixes #3717 * Add comment
-rw-r--r--modules/caddyhttp/server.go8
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 {