From 189965c96703ce178868fc27dec551451d93a429 Mon Sep 17 00:00:00 2001 From: Kane York Date: Wed, 30 Mar 2016 17:33:45 -0700 Subject: [PATCH] Allow 'upgrade' anywhere in connection header --- socketserver/server/handlecore.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/socketserver/server/handlecore.go b/socketserver/server/handlecore.go index ed0f41f4..0335e1f8 100644 --- a/socketserver/server/handlecore.go +++ b/socketserver/server/handlecore.go @@ -4,7 +4,6 @@ import ( "encoding/json" "errors" "fmt" - "github.com/gorilla/websocket" "io" "io/ioutil" "log" @@ -12,6 +11,7 @@ import ( "net/url" "os" "os/signal" + "regexp" "runtime" "strconv" "strings" @@ -20,7 +20,8 @@ import ( "syscall" "time" "unicode/utf8" - "regexp" + + "github.com/gorilla/websocket" ) // SuccessCommand is a Reply Command to indicate success in reply to a C2S Command. @@ -52,6 +53,7 @@ const defaultMinMemoryKB = 1024 * 24 // DotTwitchDotTv is the .twitch.tv suffix. const DotTwitchDotTv = ".twitch.tv" + var OriginRegexp = regexp.MustCompile(DotTwitchDotTv + "$") // ResponseSuccess is a Reply ClientMessage with the MessageID not yet filled out. @@ -205,7 +207,7 @@ func HTTPHandleRootURL(w http.ResponseWriter, r *http.Request) { return } - if r.Header.Get("Connection") == "Upgrade" { + if strings.Contains(strings.ToLower(r.Header.Get("Connection")), "upgrade") { updateSysMem() if Statistics.SysMemFreeKB > 0 && Statistics.SysMemFreeKB < Configuration.MinMemoryKBytes {