Panic on aborted requests to properly close the connection
This commit is contained in:
parent
edc0a52b5a
commit
27948493aa
3 changed files with 143 additions and 16 deletions
|
@ -23,7 +23,6 @@ import (
|
|||
"github.com/stretchr/testify/require"
|
||||
ptypes "github.com/traefik/paerser/types"
|
||||
"github.com/traefik/traefik/v2/pkg/middlewares/capture"
|
||||
"github.com/traefik/traefik/v2/pkg/middlewares/recovery"
|
||||
"github.com/traefik/traefik/v2/pkg/types"
|
||||
)
|
||||
|
||||
|
@ -948,8 +947,14 @@ func doLoggingWithAbortedStream(t *testing.T, config *types.AccessLog) {
|
|||
req = req.WithContext(reqContext)
|
||||
|
||||
chain := alice.New()
|
||||
|
||||
chain = chain.Append(func(next http.Handler) (http.Handler, error) {
|
||||
return recovery.New(context.Background(), next)
|
||||
return http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
|
||||
defer func() {
|
||||
_ = recover() // ignore the stream backend panic to avoid the test to fail.
|
||||
}()
|
||||
next.ServeHTTP(rw, req)
|
||||
}), nil
|
||||
})
|
||||
chain = chain.Append(capture.Wrap)
|
||||
chain = chain.Append(WrapHandler(logger))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue