[libsoup/carlosgc/websockets-client-max-window-bits-in-response: 7/7] WebSockets: client_max_window_bits in server response must have a value



commit 6ff833f9ee573877d288a39d76cf5248b6e033de
Author: Carlos Garcia Campos <cgarcia igalia com>
Date:   Thu Sep 12 09:58:28 2019 +0200

    WebSockets: client_max_window_bits in server response must have a value
    
    The value is optional in the request offer, but not in the server
    response.
    
    Fixes: https://gitlab.gnome.org/GNOME/libsoup/issues/166

 libsoup/soup-websocket-extension-deflate.c | 13 +++----------
 tests/websocket-test.c                     |  2 +-
 2 files changed, 4 insertions(+), 11 deletions(-)
---
diff --git a/libsoup/soup-websocket-extension-deflate.c b/libsoup/soup-websocket-extension-deflate.c
index dda27c73..c7864426 100644
--- a/libsoup/soup-websocket-extension-deflate.c
+++ b/libsoup/soup-websocket-extension-deflate.c
@@ -44,8 +44,7 @@ typedef enum {
         PARAM_SERVER_NO_CONTEXT_TAKEOVER   = 1 << 0,
         PARAM_CLIENT_NO_CONTEXT_TAKEOVER   = 1 << 1,
         PARAM_SERVER_MAX_WINDOW_BITS       = 1 << 2,
-        PARAM_CLIENT_MAX_WINDOW_BITS       = 1 << 3,
-        PARAM_CLIENT_MAX_WINDOW_BITS_VALUE = 1 << 4
+        PARAM_CLIENT_MAX_WINDOW_BITS       = 1 << 3
 } ParamFlags;
 
 typedef struct {
@@ -180,8 +179,6 @@ parse_params (GHashTable *params,
                         if (value) {
                                 if (!parse_window_bits ((char *)value, &out->client_max_window_bits))
                                         return return_invalid_param_value_error(error, 
"client_max_window_bits");
-
-                                out->flags |= PARAM_CLIENT_MAX_WINDOW_BITS_VALUE;
                         } else {
                                 out->client_max_window_bits = 15;
                         }
@@ -274,12 +271,8 @@ soup_websocket_extension_deflate_get_response_params (SoupWebsocketExtension *ex
                 params = g_string_append (params, "; client_no_context_takeover");
         if (priv->params.flags & PARAM_SERVER_MAX_WINDOW_BITS)
                 g_string_append_printf (params, "; server_max_window_bits=%u", 
priv->params.server_max_window_bits);
-        if (priv->params.flags & PARAM_CLIENT_MAX_WINDOW_BITS) {
-                if (priv->params.flags & PARAM_CLIENT_MAX_WINDOW_BITS_VALUE)
-                        g_string_append_printf (params, "; client_max_window_bits=%u", 
priv->params.client_max_window_bits);
-                else
-                        params = g_string_append (params, "; client_max_window_bits");
-        }
+        if (priv->params.flags & PARAM_CLIENT_MAX_WINDOW_BITS)
+               g_string_append_printf (params, "; client_max_window_bits=%u", 
priv->params.client_max_window_bits);
 
         return g_string_free (params, FALSE);
 }
diff --git a/tests/websocket-test.c b/tests/websocket-test.c
index 6381f4b7..b5142612 100644
--- a/tests/websocket-test.c
+++ b/tests/websocket-test.c
@@ -1486,7 +1486,7 @@ static struct {
        { "permessage-deflate; client_max_window_bits",
          /* prepare supported check accepted verify */
               TRUE,    TRUE,   TRUE,  TRUE,   TRUE,
-         "permessage-deflate; client_max_window_bits"
+         "permessage-deflate; client_max_window_bits=15"
        },
        { "permessage-deflate; client_max_window_bits=10",
          /* prepare supported check accepted verify */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]