[COMMIT seastar master] websocket: change the response type to BINARY

0 views
Skip to first unread message

Commit Bot

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

websocket: change the response type to BINARY

... in order to work properly with browsers, which expect it by default.
Actually, it's probably the handler that should declare what type of
results it returns, but that can be fixed in a follow-up.

---
diff --git a/src/websocket/server.cc b/src/websocket/server.cc
--- a/src/websocket/server.cc
+++ b/src/websocket/server.cc
@@ -371,7 +371,7 @@ future<> connection::response_loop() {
// FIXME: implement error handling
return _output_buffer.pop_eventually().then([this] (
temporary_buffer<char> buf) {
- return send_data(opcodes::TEXT, std::move(buf));
+ return send_data(opcodes::BINARY, std::move(buf));
});
}).finally([this]() {
return _write_buf.close();
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
@@ -140,11 +140,11 @@ SEASTAR_TEST_CASE(test_websocket_handler_registration) {

// Sending and receiving a websocket frame
const auto ws_frame = std::string(
- "\201\204" // 1000 0001 1000 0100
+ "\202\204" // 1000 0002 1000 0100
"TEST" // Masking Key
"\0\0\0\0", 10); // Masked Message - TEST
const auto rs_frame = std::string(
- "\201\004" // 1000 0001 0000 0100
+ "\202\004" // 1000 0002 0000 0100
"TEST", 6); // Message - TEST
output.write(ws_frame).get();
output.flush().get();
Reply all
Reply to author
Forward
0 new messages