From 52df747930ebe4a4a9308fdd2b83f01466d434da Mon Sep 17 00:00:00 2001 From: Hemanth Kumar Mantri Date: Fri, 17 Mar 2017 18:51:02 -0700 Subject: [PATCH] Add HTTP status code to ErrBadStatus When the websocket handshake fails there is no way the client can figure out what's wrong if we don't specify the HTTP response code. This change appends the HTTP status code to the error message. --- websocket/hybi.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/websocket/hybi.go b/websocket/hybi.go index 8cffdd16c..7b78729b4 100644 --- a/websocket/hybi.go +++ b/websocket/hybi.go @@ -20,6 +20,7 @@ import ( "net/http" "net/url" "strings" + "strconv" ) const ( @@ -442,6 +443,7 @@ func hybiClientHandshake(config *Config, br *bufio.Reader, bw *bufio.Writer) (er return err } if resp.StatusCode != 101 { + ErrBadStatus.ErrorString = "bad status: " + strconv.Itoa(resp.StatusCode) return ErrBadStatus } if strings.ToLower(resp.Header.Get("Upgrade")) != "websocket" ||