http3: handle ErrAbortHandler when the handler panics (#3575)

* Handle abort like the stdlib does

* Using the sentinel value from the stdlib instead of redefining.

* we return before logging out

* Added test to hand abort handler

* Added in two tests but apparently only saved the first one.

* remove one test case because it wasn't needed
This commit is contained in:
shade34321
2022-10-09 10:50:04 -04:00
committed by GitHub
parent 424a66389c
commit a905648480
2 changed files with 21 additions and 1 deletions

View File

@@ -576,12 +576,15 @@ func (s *Server) handleRequest(conn quic.Connection, str quic.Stream, decoder *q
func() {
defer func() {
if p := recover(); p != nil {
panicked = true
if p == http.ErrAbortHandler {
return
}
// Copied from net/http/server.go
const size = 64 << 10
buf := make([]byte, size)
buf = buf[:runtime.Stack(buf, false)]
s.logger.Errorf("http: panic serving: %v\n%s", p, buf)
panicked = true
}
}()
handler.ServeHTTP(r, req)