client ext hdr skip if no arg
authorAndy Green <andy.green@linaro.org>
Wed, 9 Mar 2016 15:35:41 +0000 (23:35 +0800)
committerAndy Green <andy.green@linaro.org>
Wed, 9 Mar 2016 15:35:41 +0000 (23:35 +0800)
https://github.com/warmcat/libwebsockets/issues/453

Signed-off-by: Andy Green <andy.green@linaro.org>
changelog
lib/client.c

index ba12a03b53039ad916e8c7bfb854097d81472b82..88367dbc8936443ea4dd1169608a48900cfc72bd 100644 (file)
--- a/changelog
+++ b/changelog
@@ -1,6 +1,11 @@
 Changelog
 ---------
 
+Fixes
+-----
+
+1) MINOR: d9n't send ext hdr if no exts to discuss
+
 v1.7.3
 ======
 
index 33d990e410b6b7c227450df420befb60b4e7d5bd..1ba809b9fdf4fcdbe7de37f134a383c3f14d8c4b 100644 (file)
@@ -956,7 +956,6 @@ lws_generate_client_handshake(struct lws *wsi, char *pkt)
 
        /* tell the server what extensions we could support */
 
-       p += sprintf(p, "Sec-WebSocket-Extensions: ");
 #ifndef LWS_NO_EXTENSIONS
        ext = context->extensions;
        while (ext && ext->callback) {
@@ -988,13 +987,17 @@ lws_generate_client_handshake(struct lws *wsi, char *pkt)
 
                if (ext_count)
                        *p++ = ',';
+                else
+                        p += sprintf(p, "Sec-WebSocket-Extensions: ");
+
                p += sprintf(p, "%s", ext->client_offer);
                ext_count++;
 
                ext++;
        }
+       if (ext_count)
+               p += sprintf(p, "\x0d\x0a");
 #endif
-       p += sprintf(p, "\x0d\x0a");
 
        if (wsi->ietf_spec_revision)
                p += sprintf(p, "Sec-WebSocket-Version: %d\x0d\x0a",