forked from quic-go/quic-go
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:
@@ -201,6 +201,23 @@ var _ = Describe("Server", func() {
|
||||
Expect(hfs).To(HaveKeyWithValue(":status", []string{"200"}))
|
||||
})
|
||||
|
||||
It("handles a aborting handler", func() {
|
||||
s.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
panic(http.ErrAbortHandler)
|
||||
})
|
||||
|
||||
responseBuf := &bytes.Buffer{}
|
||||
setRequest(encodeRequest(exampleGetRequest))
|
||||
str.EXPECT().Context().Return(reqContext)
|
||||
str.EXPECT().Write(gomock.Any()).DoAndReturn(responseBuf.Write).AnyTimes()
|
||||
str.EXPECT().CancelRead(gomock.Any())
|
||||
|
||||
serr := s.handleRequest(conn, str, qpackDecoder, nil)
|
||||
Expect(serr.err).ToNot(HaveOccurred())
|
||||
hfs := decodeHeader(responseBuf)
|
||||
Expect(hfs).To(HaveKeyWithValue(":status", []string{"500"}))
|
||||
})
|
||||
|
||||
It("handles a panicking handler", func() {
|
||||
s.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
panic("foobar")
|
||||
|
||||
Reference in New Issue
Block a user