diff options
| author | Shulhan <ms@kilabit.info> | 2019-03-16 15:56:30 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2019-03-17 02:15:15 +0700 |
| commit | a11c86647f5b7b7b5d2f88a72cdc5eb7c026a84d (patch) | |
| tree | d31b97d81bffa49189169413cf1fcf88ca7da663 | |
| parent | 409cb90129f8798ec55141123f7d97d68691baf8 (diff) | |
| download | pakakeh.go-a11c86647f5b7b7b5d2f88a72cdc5eb7c026a84d.tar.xz | |
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.
| -rw-r--r-- | lib/websocket/client.go | 10 |
1 files changed, 9 insertions, 1 deletions
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) |
