From 6664997ae7091f1158374030fed30521d6e368d8 Mon Sep 17 00:00:00 2001 From: Marcin Wrochniak Date: Wed, 16 Aug 2017 13:48:39 +0200 Subject: [PATCH] Drop the connection on context cancellation --- wsutil.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/wsutil.go b/wsutil.go index cee4702..b86f953 100644 --- a/wsutil.go +++ b/wsutil.go @@ -160,7 +160,10 @@ func (p *ReverseProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) { } go cp(d, nc) go cp(nc, d) - <-errc + select { + case <-errc: + case <-r.Context().Done(): + } } // IsWebSocketRequest returns a boolean indicating whether the request has the