Compare commits

..

2 Commits

2 changed files with 6 additions and 7 deletions

View File

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

View File

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