From 15601fd8f10b9e1b0774235e8a9298c47707f363 Mon Sep 17 00:00:00 2001 From: Andy Green Date: Thu, 29 Mar 2012 09:27:13 +0800 Subject: [PATCH] fix issuing null extension header if none supported 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 Signed-off-by: Andy Green --- lib/handshake.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/handshake.c b/lib/handshake.c index c22c406..dafccef 100644 --- a/lib/handshake.c +++ b/lib/handshake.c @@ -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"); -- 2.7.4