Skip to content

Commit

Permalink
Issue #183: Websocket header casing
Browse files Browse the repository at this point in the history
The value of the Upgrade header can either be
"websocket" or "Websocket".
  • Loading branch information
magiconair committed Nov 4, 2016
1 parent 1b5df2c commit 85d29a6
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions proxy/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 85d29a6

Please sign in to comment.