[COMMIT seastar master] websocket: add resending subprotocol header

0 views
Skip to first unread message

Commit Bot

<bot@cloudius-systems.com>
unread,
Jun 23, 2022, 8:25:57 AM6/23/22
to seastar-dev@googlegroups.com, kozakusek
From: kozakusek <bk41...@students.mimuw.edu.pl>
Committer: Piotr Sarna <sa...@scylladb.com>
Branch: master

websocket: add resending subprotocol header

This is required by some browsers (e.g. chrome), while
it already works fine on others (e.g. firefox).
The test is updated to swallow the larger response.

---
diff --git a/src/websocket/server.cc b/src/websocket/server.cc
--- a/src/websocket/server.cc
+++ b/src/websocket/server.cc
@@ -173,6 +173,10 @@ future<> connection::read_http_upgrade_request() {

return _write_buf.write(http_upgrade_reply_template).then([this, sha1_output = std::move(sha1_output)] {
return _write_buf.write(sha1_output);
+ }).then([this] {
+ return _write_buf.write("\r\nSec-WebSocket-Protocol: ", 26);
+ }).then([this] {
+ return _write_buf.write(_subprotocol);
}).then([this] {
return _write_buf.write("\r\n\r\n", 4);
}).then([this] {
diff --git a/tests/unit/websocket_test.cc b/tests/unit/websocket_test.cc
--- a/tests/unit/websocket_test.cc
+++ b/tests/unit/websocket_test.cc
@@ -136,7 +136,7 @@ SEASTAR_TEST_CASE(test_websocket_handler_registration) {
"\r\n";
output.write(request).get();
output.flush().get();
- input.read_exactly(156).get();
+ input.read_exactly(186).get();

// Sending and receiving a websocket frame
const auto ws_frame = std::string(
Reply all
Reply to author
Forward
0 new messages