Browse Source
caddyhttp: Restore original request params before error handlers (#3781)
* caddyhttp: Restore original request params before error handlers
Fixes #3717
* Add comment
master
Matt Holt
5 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
8 additions and
0 deletions
-
modules/caddyhttp/server.go
|
@ -209,6 +209,14 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) { |
|
|
return |
|
|
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
|
|
|
// prepare the error log
|
|
|
logger := errLog |
|
|
logger := errLog |
|
|
if s.Logs != nil { |
|
|
if s.Logs != nil { |
|
|