fix issuing null extension header if none supported
authorAndy Green <andy@warmcat.com>
Thu, 29 Mar 2012 01:27:13 +0000 (09:27 +0800)
committerAndy Green <andy.green@linaro.org>
Thu, 29 Mar 2012 01:27:13 +0000 (09:27 +0800)
Josh realized that with new Chrome, because we don't support the type of
compression extension yet we returned a null extension header.

This patch fixes that by deferring issuing the extension header until we
find we have something to say.

tested OK on google-chrome 19.0.1081.2-129295

Reported-by: Josh Roberson <josh@asteriasgi.com>
Signed-off-by: Andy Green <andy.green@linaro.org>
lib/handshake.c

index c22c406..dafccef 100644 (file)
@@ -340,8 +340,6 @@ handshake_0405(struct libwebsocket_context *context, struct libwebsocket *wsi)
         */
 
        if (wsi->utf8_token[WSI_TOKEN_EXTENSIONS].token_len) {
-               strcpy(p,   "\x0d\x0aSec-WebSocket-Extensions: ");
-               p += strlen("\x0d\x0aSec-WebSocket-Extensions: ");
 
                /*
                 * break down the list of client extensions
@@ -410,6 +408,10 @@ handshake_0405(struct libwebsocket_context *context, struct libwebsocket *wsi)
                                
                                if (ext_count)
                                        *p++ = ',';
+                               else {
+                                       strcpy(p,   "\x0d\x0aSec-WebSocket-Extensions: ");
+                                       p += strlen("\x0d\x0aSec-WebSocket-Extensions: ");
+                               }
                                p += sprintf(p, "%s", ext_name);
                                ext_count++;
 
@@ -444,7 +446,6 @@ handshake_0405(struct libwebsocket_context *context, struct libwebsocket *wsi)
                }
        }
 
-
        /* end of response packet */
 
        strcpy(p,   "\x0d\x0a\x0d\x0a");