fix: ignore timeout on websocket (#1802)
This commit is contained in:
@@ -20,6 +20,8 @@ import (
|
||||
const (
|
||||
statusClientClosedRequest = 499
|
||||
reason = "Request Timeout"
|
||||
headerUpgrade = "Upgrade"
|
||||
valueWebsocket = "websocket"
|
||||
)
|
||||
|
||||
// TimeoutHandler returns the handler with given timeout.
|
||||
@@ -52,6 +54,11 @@ func (h *timeoutHandler) errorBody() string {
|
||||
}
|
||||
|
||||
func (h *timeoutHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Header.Get(headerUpgrade) == valueWebsocket {
|
||||
h.handler.ServeHTTP(w, r)
|
||||
return
|
||||
}
|
||||
|
||||
ctx, cancelCtx := context.WithTimeout(r.Context(), h.dt)
|
||||
defer cancelCtx()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user