diff options
author | Kyle Russell <kyle.russell@lexmark.com> | 2016-11-01 15:47:25 -0400 |
---|---|---|
committer | Kyle Russell <bkylerussell@gmail.com> | 2016-12-08 20:58:47 -0500 |
commit | aed23ae5c3b1e5d20646733c590edfaef16940d4 (patch) | |
tree | 505baf91397911f860aa5e1b845f6e2b9e68ec7f /libvncserver/websockets.c | |
parent | 74886843969527f0527aa351761e4d6864b846ac (diff) | |
download | libtdevnc-aed23ae5c3b1e5d20646733c590edfaef16940d4.tar.gz libtdevnc-aed23ae5c3b1e5d20646733c590edfaef16940d4.zip |
websockets: Don't supply Sec-WebSocket-Protocol if not in request
Diffstat (limited to 'libvncserver/websockets.c')
-rw-r--r-- | libvncserver/websockets.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/libvncserver/websockets.c b/libvncserver/websockets.c index b5d99fc..bdec8f3 100644 --- a/libvncserver/websockets.c +++ b/libvncserver/websockets.c @@ -153,6 +153,11 @@ Sec-WebSocket-Accept: %s\r\n\ Sec-WebSocket-Protocol: %s\r\n\ \r\n" +#define SERVER_HANDSHAKE_HYBI_NO_PROTOCOL "HTTP/1.1 101 Switching Protocols\r\n\ +Upgrade: websocket\r\n\ +Connection: Upgrade\r\n\ +Sec-WebSocket-Accept: %s\r\n\ +\r\n" #define WEBSOCKETS_CLIENT_CONNECT_WAIT_MS 100 #define WEBSOCKETS_CLIENT_SEND_WAIT_MS 100 @@ -390,8 +395,12 @@ webSocketsHandshake(rfbClientPtr cl, char *scheme) char accept[B64LEN(SHA1_HASH_SIZE) + 1]; rfbLog(" - WebSockets client version hybi-%02d\n", sec_ws_version); webSocketsGenSha1Key(accept, sizeof(accept), sec_ws_key); - len = snprintf(response, WEBSOCKETS_MAX_HANDSHAKE_LEN, - SERVER_HANDSHAKE_HYBI, accept, protocol); + if(strlen(protocol) > 0) + len = snprintf(response, WEBSOCKETS_MAX_HANDSHAKE_LEN, + SERVER_HANDSHAKE_HYBI, accept, protocol); + else + len = snprintf(response, WEBSOCKETS_MAX_HANDSHAKE_LEN, + SERVER_HANDSHAKE_HYBI_NO_PROTOCOL, accept); } else { /* older hixie handshake, this could be removed if * a final standard is established */ |