mirror of
https://codeberg.org/git-pages/git-pages.git
synced 2026-05-14 03:01:48 +00:00
Re-throw http.ErrAbortHandler from our panic handler.
This aborts the response to the client and doesn't log an error. httputil.ReverseProxy commonly panics with this error. This results in different behavior from simply swallowing the panic. Panicking prevents flushing the response to the client, and in the case of a panic from httputil.ReverseProxy it results in clients potentially receiving an empty response instead of what was already written to http.ResponseWriter. This behavior is the same as if the panic handler hadn't been installed.
This commit is contained in:
@@ -127,6 +127,9 @@ func panicHandler(handler http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
defer func() {
|
||||
if err := recover(); err != nil {
|
||||
if err, ok := err.(error); ok && errors.Is(err, http.ErrAbortHandler) {
|
||||
panic(http.ErrAbortHandler)
|
||||
}
|
||||
logc.Printf(r.Context(), "panic: %s %s %s: %s\n%s",
|
||||
r.Method, r.Host, r.URL.Path, err, string(debug.Stack()))
|
||||
http.Error(w,
|
||||
|
||||
Reference in New Issue
Block a user