summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Green <andy@warmcat.com>2016-12-10 09:14:37 +0800
committerDmitry Kovalenko <d.kovalenko@samsung.com>2016-12-16 11:19:28 +0300
commit348ec0844fbe1471c918d788df6aa0c1db82ba13 (patch)
tree489dc3d41647c5aa6849bea16a3a7da6822916dd
parentd93d28416159b5501c1dc5bacc499ef83138ea2b (diff)
downloadlibwebsockets-accepted/tizen_3.0_wearable.tar.gz
libwebsockets-accepted/tizen_3.0_wearable.tar.bz2
libwebsockets-accepted/tizen_3.0_wearable.zip
https://libwebsockets.org/pipermail/libwebsockets/2016-November/002948.html Updated to fix a problem with no protocol https://github.com/warmcat/libwebsockets/issues/705 Change-Id: I06e9f9d5849e66291b246316008c6e2c5981a372
-rw-r--r--lib/server-handshake.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/server-handshake.c b/lib/server-handshake.c
index 7328e5e2..ed257dea 100644
--- a/lib/server-handshake.c
+++ b/lib/server-handshake.c
@@ -214,7 +214,12 @@ handshake_0405(struct lws_context *context, struct lws *wsi)
strcpy(p, (char *)pt->serv_buf);
p += accept_len;
- if (wsi->protocol->name && wsi->protocol->name[0]) {
+ /* we can only return the protocol header if:
+ * - one came in, and ... */
+ if (lws_hdr_total_length(wsi, WSI_TOKEN_PROTOCOL) &&
+ /* - it is not an empty string */
+ wsi->protocol->name &&
+ wsi->protocol->name[0]) {
LWS_CPYAPP(p, "\x0d\x0aSec-WebSocket-Protocol: ");
p += lws_snprintf(p, 128, "%s", wsi->protocol->name);
}