diff options
author | Lukáš Tyrychtr <lukastyrychtr@gmail.com> | 2022-11-24 09:17:56 +0000 |
---|---|---|
committer | Carlos Garcia Campos <carlosgc@gnome.org> | 2022-11-24 09:17:56 +0000 |
commit | 8d5f7c4355be873c812aba44bd2b5e30727511e2 (patch) | |
tree | 8671a0fcb9cb6d177176a642a27a289a8fa2d1a9 /libsoup | |
parent | 7328710927154033e0d4f5bf429f03ea3b210a54 (diff) | |
download | libsoup-8d5f7c4355be873c812aba44bd2b5e30727511e2.tar.gz |
soupWebsocket: don't add the protocols header if it would be empty
Fixes #314
Diffstat (limited to 'libsoup')
-rw-r--r-- | libsoup/websocket/soup-websocket.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/libsoup/websocket/soup-websocket.c b/libsoup/websocket/soup-websocket.c index f0829d4e..64e66fd0 100644 --- a/libsoup/websocket/soup-websocket.c +++ b/libsoup/websocket/soup-websocket.c @@ -209,7 +209,7 @@ choose_subprotocol (SoupServerMessage *msg, client_protocols = g_strsplit_set (client_protocols_str, ", ", -1); if (!client_protocols || !client_protocols[0]) { g_strfreev (client_protocols); - return TRUE; + return FALSE; } for (i = 0; server_protocols[i] != NULL; i++) { @@ -273,12 +273,13 @@ soup_websocket_client_prepare_handshake (SoupMessage *msg, if (origin) soup_message_headers_replace_common (soup_message_get_request_headers (msg), SOUP_HEADER_ORIGIN, origin); - if (protocols) { + if (protocols && *protocols) { char *protocols_str; protocols_str = g_strjoinv (", ", protocols); - soup_message_headers_replace_common (soup_message_get_request_headers (msg), - SOUP_HEADER_SEC_WEBSOCKET_PROTOCOL, protocols_str); + if (*protocols_str) + soup_message_headers_replace_common (soup_message_get_request_headers (msg), + SOUP_HEADER_SEC_WEBSOCKET_PROTOCOL, protocols_str); g_free (protocols_str); } |