Skip to content

Commit 385adf5

Browse files
authored
caddyhttp: Restore original request params before error handlers (#3781)
* caddyhttp: Restore original request params before error handlers Fixes #3717 * Add comment
1 parent c7efb03 commit 385adf5

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

modules/caddyhttp/server.go

+8
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,14 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
209209
return
210210
}
211211

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+
212220
// prepare the error log
213221
logger := errLog
214222
if s.Logs != nil {

0 commit comments

Comments
 (0)