From a11c86647f5b7b7b5d2f88a72cdc5eb7c026a84d Mon Sep 17 00:00:00 2001 From: Shulhan Date: Sat, 16 Mar 2019 15:56:30 +0700 Subject: websocket: fix empty path when generating client handshake request Also, check if the Endpoint URL contains query parameter before appending the "?" to handshake request path. --- lib/websocket/client.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/websocket/client.go b/lib/websocket/client.go index 4400e12e..508563f7 100644 --- a/lib/websocket/client.go +++ b/lib/websocket/client.go @@ -286,7 +286,15 @@ func (cl *Client) open() (err error) { func (cl *Client) handshake() (err error) { var bb bytes.Buffer - path := cl.remoteURL.EscapedPath() + "?" + cl.remoteURL.RawQuery + path := cl.remoteURL.EscapedPath() + if len(path) == 0 { + path = "/" + } + + if len(cl.remoteURL.RawQuery) > 0 { + path += "?" + cl.remoteURL.RawQuery + } + key := generateHandshakeKey() keyAccept := generateHandshakeAccept(key) -- cgit v1.3