From 85d29a6e1c64044c0fb4f30159142d01f8cc651c Mon Sep 17 00:00:00 2001 From: Frank Schroeder Date: Sat, 5 Nov 2016 08:14:11 +1300 Subject: [PATCH] Issue #183: Websocket header casing The value of the Upgrade header can either be "websocket" or "Websocket". --- proxy/proxy.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/proxy/proxy.go b/proxy/proxy.go index cd199258e..b063139fe 100644 --- a/proxy/proxy.go +++ b/proxy/proxy.go @@ -44,15 +44,17 @@ func (p *httpProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) { return } + upgrade, accept := r.Header.Get("Upgrade"), r.Header.Get("Accept") + var h http.Handler switch { - case r.Header.Get("Upgrade") == "websocket": + case upgrade == "websocket" || upgrade == "Websocket": h = newRawProxy(t.URL) // To use the filtered proxy use // h = newWSProxy(t.URL) - case r.Header.Get("Accept") == "text/event-stream": + case accept == "text/event-stream": // use the flush interval for SSE (server-sent events) // must be > 0s to be effective h = newHTTPProxy(t.URL, p.tr, p.cfg.FlushInterval)