diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2024-01-14 10:24:41 +0100 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2024-02-01 21:38:53 +0100 |
commit | 6cfb31c306b9deb120a9fb5c564a1456a72af665 (patch) | |
tree | 44b1cc7940b852d4fd215a5b269365b9652ac3ba /tests/unit/plugins/relay/test-relay-http.cpp | |
parent | 8971fc069a1c1a9e8c3f6fa1f83e64a50b2876c1 (diff) | |
download | weechat-6cfb31c306b9deb120a9fb5c564a1456a72af665.zip |
relay: add support of websocket extension "permessage-deflate" (closes #1549)
This extension is used to compress and decompress websocket frames (using
the DEFLATE algorithm, with zlib).
Diffstat (limited to 'tests/unit/plugins/relay/test-relay-http.cpp')
-rw-r--r-- | tests/unit/plugins/relay/test-relay-http.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/unit/plugins/relay/test-relay-http.cpp b/tests/unit/plugins/relay/test-relay-http.cpp index b3ad96890..64bb7b752 100644 --- a/tests/unit/plugins/relay/test-relay-http.cpp +++ b/tests/unit/plugins/relay/test-relay-http.cpp @@ -34,6 +34,7 @@ extern "C" #include "src/core/wee-string.h" #include "src/plugins/relay/relay-config.h" #include "src/plugins/relay/relay-http.h" +#include "src/plugins/relay/relay-websocket.h" #include "src/plugins/weechat-plugin.h" extern char *relay_http_url_decode (const char *url); @@ -89,6 +90,14 @@ TEST(RelayHttp, AllocReinitFree) LONGS_EQUAL(0, request->headers->items_count); CHECK(request->accept_encoding); LONGS_EQUAL(0, request->accept_encoding->items_count); + CHECK(request->ws_deflate); + LONGS_EQUAL(0, request->ws_deflate->enabled); + LONGS_EQUAL(0, request->ws_deflate->server_context_takeover); + LONGS_EQUAL(0, request->ws_deflate->server_context_takeover); + LONGS_EQUAL(0, request->ws_deflate->window_bits_deflate); + LONGS_EQUAL(0, request->ws_deflate->window_bits_inflate); + POINTERS_EQUAL(NULL, request->ws_deflate->strm_deflate); + POINTERS_EQUAL(NULL, request->ws_deflate->strm_inflate); LONGS_EQUAL(0, request->content_length); LONGS_EQUAL(0, request->body_size); POINTERS_EQUAL(NULL, request->body); @@ -102,6 +111,7 @@ TEST(RelayHttp, AllocReinitFree) request->http_version = strdup ("HTTP/1.1"); hashtable_set (request->headers, "x-test", "value"); hashtable_set (request->accept_encoding, "gzip", ""); + request->ws_deflate->enabled = 1; request->content_length = 100; request->body_size = 16; request->body = (char *)malloc (16); @@ -123,6 +133,14 @@ TEST(RelayHttp, AllocReinitFree) LONGS_EQUAL(0, request->headers->items_count); CHECK(request->accept_encoding); LONGS_EQUAL(0, request->accept_encoding->items_count); + CHECK(request->ws_deflate); + LONGS_EQUAL(0, request->ws_deflate->enabled); + LONGS_EQUAL(0, request->ws_deflate->server_context_takeover); + LONGS_EQUAL(0, request->ws_deflate->server_context_takeover); + LONGS_EQUAL(0, request->ws_deflate->window_bits_deflate); + LONGS_EQUAL(0, request->ws_deflate->window_bits_inflate); + POINTERS_EQUAL(NULL, request->ws_deflate->strm_deflate); + POINTERS_EQUAL(NULL, request->ws_deflate->strm_inflate); LONGS_EQUAL(0, request->content_length); LONGS_EQUAL(0, request->body_size); POINTERS_EQUAL(NULL, request->body); @@ -477,6 +495,29 @@ TEST(RelayHttp, ParseHeader) LONGS_EQUAL(1, request->headers->items_count); LONGS_EQUAL(123, request->content_length); free (request); + + /* websocket request */ + request = relay_http_request_alloc (); + CHECK(request); + relay_http_parse_method_path (request, "GET /api HTTP/1.1"); + relay_http_parse_header ( + request, + "Sec-WebSocket-Extensions: permessage-deflate; client_max_window_bits"); + LONGS_EQUAL(RELAY_HTTP_HEADERS, request->status); + STRCMP_EQUAL( + "GET /api HTTP/1.1\n" + "Sec-WebSocket-Extensions: permessage-deflate; client_max_window_bits\n", + *(request->raw)); + LONGS_EQUAL(1, request->headers->items_count); + CHECK(request->ws_deflate); + LONGS_EQUAL(1, request->ws_deflate->enabled); + LONGS_EQUAL(1, request->ws_deflate->server_context_takeover); + LONGS_EQUAL(1, request->ws_deflate->server_context_takeover); + LONGS_EQUAL(15, request->ws_deflate->window_bits_deflate); + LONGS_EQUAL(15, request->ws_deflate->window_bits_inflate); + POINTERS_EQUAL(NULL, request->ws_deflate->strm_deflate); + POINTERS_EQUAL(NULL, request->ws_deflate->strm_inflate); + free (request); } /* |