diff --git a/.github/workflows/test-arch-linux.yml b/.github/workflows/test-arch-linux.yml index 73d4b083..64422002 100644 --- a/.github/workflows/test-arch-linux.yml +++ b/.github/workflows/test-arch-linux.yml @@ -11,7 +11,7 @@ on: - main env: - TWITCH_PUBSUB_SERVER_TAG: v1.0.11 + TWITCH_PUBSUB_SERVER_TAG: v1.0.12 HTTPBOX_TAG: v0.2.1 QT_QPA_PLATFORM: minimal diff --git a/.github/workflows/test-macos.yml b/.github/workflows/test-macos.yml index 6528e5d1..5f883435 100644 --- a/.github/workflows/test-macos.yml +++ b/.github/workflows/test-macos.yml @@ -7,7 +7,7 @@ on: merge_group: env: - TWITCH_PUBSUB_SERVER_TAG: v1.0.11 + TWITCH_PUBSUB_SERVER_TAG: v1.0.12 HTTPBOX_TAG: v0.2.1 QT_QPA_PLATFORM: minimal HOMEBREW_NO_AUTO_UPDATE: 1 diff --git a/.github/workflows/test-windows.yml b/.github/workflows/test-windows.yml index f799700c..4eb8d619 100644 --- a/.github/workflows/test-windows.yml +++ b/.github/workflows/test-windows.yml @@ -7,7 +7,7 @@ on: merge_group: env: - TWITCH_PUBSUB_SERVER_TAG: v1.0.11 + TWITCH_PUBSUB_SERVER_TAG: v1.0.12 HTTPBOX_TAG: v0.2.1 QT_QPA_PLATFORM: minimal CONAN_VERSION: 2.11.0 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 976dd406..99db2586 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,7 +11,7 @@ on: - main env: - TWITCH_PUBSUB_SERVER_TAG: v1.0.11 + TWITCH_PUBSUB_SERVER_TAG: v1.0.12 HTTPBOX_TAG: v0.2.1 QT_QPA_PLATFORM: minimal diff --git a/CHANGELOG.md b/CHANGELOG.md index 61e97245..ce42aaf1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ - Bugfix: Fixed settings occasionally not opening when clicking on "Manage Accounts" in the account switcher. (#6543) - Bugfix: Fixed font change not resulting in forced layout update. (#6536) - Bugfix: Fixed scrollbar rect computation potentially resulting in overflows. (#6547) +- Bugfix: Forward query params to websocket URLs. (#6141) - Dev: Update release documentation. (#6498) - Dev: Make code sanitizers opt in with the `CHATTERINO_SANITIZER_SUPPORT` CMake option. After that's enabled, use the `SANITIZE_*` flag to enable individual sanitizers. (#6493) - Dev: Remove unused QTextCodec includes. (#6487) diff --git a/src/common/websockets/detail/WebSocketConnectionImpl.cpp b/src/common/websockets/detail/WebSocketConnectionImpl.cpp index 0fdd5a8f..b4b9d8d1 100644 --- a/src/common/websockets/detail/WebSocketConnectionImpl.cpp +++ b/src/common/websockets/detail/WebSocketConnectionImpl.cpp @@ -167,13 +167,18 @@ void WebSocketConnectionHelper::doWsHandshake() auto host = this->options.url.host(QUrl::FullyEncoded).toStdString() + ':' + std::to_string(this->options.url.port(Derived::DEFAULT_PORT)); - auto path = this->options.url.path(QUrl::FullyEncoded).toStdString(); - if (path.empty()) + auto path = this->options.url.path(QUrl::FullyEncoded); + if (path.isEmpty()) { path = "/"; } + if (this->options.url.hasQuery()) + { + path += '?'; + path += this->options.url.query(QUrl::FullyEncoded); + } this->stream.async_handshake( - host, path, + host, path.toStdString(), beast::bind_front_handler(&WebSocketConnectionHelper::onWsHandshake, this->shared_from_this())); } diff --git a/tests/src/WebSocketPool.cpp b/tests/src/WebSocketPool.cpp index efbf5713..821295ed 100644 --- a/tests/src/WebSocketPool.cpp +++ b/tests/src/WebSocketPool.cpp @@ -61,7 +61,7 @@ TEST(WebSocketPool, tcpEcho) auto handle = pool.createSocket( { - .url = QUrl("ws://127.0.0.1:9052/echo"), + .url = QUrl("ws://127.0.0.1:9052/echo?query=123&xd=wow"), .headers = { {"My-Header", "my-header-VALUE"}, @@ -85,11 +85,12 @@ TEST(WebSocketPool, tcpEcho) handle.sendText("/HEADER another-header"); handle.sendText("/HEADER cookie"); handle.sendText("/HEADER user-agent"); + handle.sendText("/URL"); handle.sendText("/CLOSE"); ASSERT_TRUE(closeFlag.waitFor(1s)); - ASSERT_EQ(messages.size(), 10); + ASSERT_EQ(messages.size(), 11); ASSERT_EQ(messages[0].first, false); ASSERT_EQ(messages[0].second, "message1"); ASSERT_EQ(messages[1].first, false); @@ -110,6 +111,8 @@ TEST(WebSocketPool, tcpEcho) ASSERT_EQ(messages[8].second, "xd"); ASSERT_EQ(messages[9].first, true); ASSERT_EQ(messages[9].second, "MyUserAgent"); + ASSERT_EQ(messages[10].first, true); + ASSERT_EQ(messages[10].second, "/echo?query=123&xd=wow"); } TEST(WebSocketPool, tlsEcho) @@ -146,11 +149,12 @@ TEST(WebSocketPool, tlsEcho) handle.sendText("/HEADER another-header"); handle.sendText("/HEADER cookie"); handle.sendText("/HEADER user-agent"); + handle.sendText("/URL"); handle.sendText("/CLOSE"); ASSERT_TRUE(closeFlag.waitFor(1s)); - ASSERT_EQ(messages.size(), 10); + ASSERT_EQ(messages.size(), 11); ASSERT_EQ(messages[0].first, false); ASSERT_EQ(messages[0].second, "message1"); ASSERT_EQ(messages[1].first, false); @@ -171,4 +175,6 @@ TEST(WebSocketPool, tlsEcho) ASSERT_EQ(messages[8].second, "xd"); ASSERT_EQ(messages[9].first, true); ASSERT_TRUE(messages[9].second.startsWith("Chatterino")); + ASSERT_EQ(messages[10].first, true); + ASSERT_EQ(messages[10].second, "/echo"); }