Compare commits

..

2 Commits

2 changed files with 7 additions and 6 deletions

View File

@ -68,9 +68,12 @@ func CustomRecoveryWithWriter(out io.Writer, handle RecoveryFunc) HandlerFunc {
}
}
}
if e, ok := err.(error); ok && errors.Is(e, http.ErrAbortHandler) {
brokenPipe = true
}
if e, ok := err.(error); ok {
// ErrAbortHandler should be treated as broken pipe too.
if errors.Is(e, http.ErrAbortHandler) {
brokenPipe = true
}
}
if logger != nil {
const stackSkip = 3
if brokenPipe {

View File

@ -161,9 +161,7 @@ func TestPanicWithAbortHandler(t *testing.T) {
w := PerformRequest(router, http.MethodGet, "/recovery")
// TEST
assert.Equal(t, expectCode, w.Code)
out := buf.String()
assert.Contains(t, out, "net/http: abort Handler")
assert.NotContains(t, out, "panic recovered")
assert.Contains(t, buf.String(), "net/http: abort Handler")
}
func TestCustomRecoveryWithWriter(t *testing.T) {