Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
Mirrored from https://github.com/Slazee/caddy.git
Synced Nov 14, 05:15 UTC
caddyhttp: Restore original request params before error handlers (#3781)
* caddyhttp: Restore original request params before error handlers Fixes #3717 * Add comment
Matt Holt committed
Oct 13, 2020 at 10:52 UTC
385adf5d878939c381c7f73c771771d34523a1a7
1 file changed
+8
modules/caddyhttp/server.go
+8
@@ -209,6 +209,14 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
209
return
210
}
211
212
+ // restore original request before invoking error handler chain (issue #3717)
213
+ // TODO: this does not restore original headers, if modified (for efficiency)
214
+ origReq := r.Context().Value(OriginalRequestCtxKey).(http.Request)
215
+ r.Method = origReq.Method
216
+ r.RemoteAddr = origReq.RemoteAddr
217
+ r.RequestURI = origReq.RequestURI
218
+ cloneURL(origReq.URL, r.URL)
219
+
220
// prepare the error log
221
logger := errLog
222
if s.Logs != nil {