Subject: Direct extension confirmation to the negotiated protocol's callback
authoremptyVoid <emptyVoid@users.noreply.github.com>
Sat, 27 May 2017 15:51:58 +0000 (22:51 +0700)
committerAndy Green <andy@warmcat.com>
Mon, 29 May 2017 00:30:26 +0000 (08:30 +0800)
Fixes #897

Notice this means if you want to globally ban an extension, you should
no longer include the extension at context creation time.

lib/libwebsockets.h
lib/server-handshake.c
test-server/test-echo.c

index f252892..99a9595 100644 (file)
@@ -1016,8 +1016,7 @@ enum lws_callback_reasons {
         * and with in being the extension name, len is 0 and user is
         * valid.  Note though at this time the ESTABLISHED callback hasn't
         * happened yet so if you initialize user content there, user
-        * content during this callback might not be useful for anything.
-        * Notice this callback comes to protocols[0]. */
+        * content during this callback might not be useful for anything. */
        LWS_CALLBACK_CLIENT_CONFIRM_EXTENSION_SUPPORTED         = 26,
        /**< When a client
         * connection is being prepared to start a handshake to a server,
index 61fcef3..d989fdb 100644 (file)
@@ -128,7 +128,7 @@ lws_extension_server_handshake(struct lws *wsi, char **p, int budget)
                         * ask user code if it's OK to apply it on this
                         * particular connection + protocol
                         */
-                       m = wsi->vhost->protocols[0].callback(wsi,
+                       m = (wsi->protocol->callback)(wsi,
                                LWS_CALLBACK_CONFIRM_EXTENSION_OKAY,
                                wsi->user_space, ext_name, 0);
 
index df6e41e..1b1115f 100644 (file)
@@ -168,11 +168,6 @@ do_rx:
                }
                break;
 #endif
-       case LWS_CALLBACK_CLIENT_CONFIRM_EXTENSION_SUPPORTED:
-               /* reject everything else except permessage-deflate */
-               if (strcmp(in, "permessage-deflate"))
-                       return 1;
-               break;
 
        default:
                break;
@@ -203,11 +198,6 @@ static const struct lws_extension exts[] = {
                lws_extension_callback_pm_deflate,
                "permessage-deflate; client_no_context_takeover; client_max_window_bits"
        },
-       {
-               "deflate-frame",
-               lws_extension_callback_pm_deflate,
-               "deflate_frame"
-       },
        { NULL, NULL, NULL /* terminator */ }
 };