Add socket configuration options and corresponding test case for WebSocketClient. Fix #2401

This commit is contained in:
yhirose
2026-03-22 22:31:59 -04:00
parent 7178f451a4
commit 3792ce0da7
2 changed files with 60 additions and 2 deletions
+23
View File
@@ -17088,6 +17088,29 @@ TEST_F(WebSocketIntegrationTest, SubProtocolNotRequested) {
client.close();
}
TEST_F(WebSocketIntegrationTest, SocketSettings) {
ws::WebSocketClient client("ws://localhost:" + std::to_string(port_) +
"/ws-echo");
client.set_tcp_nodelay(true);
client.set_address_family(AF_INET);
client.set_connection_timeout(3, 0);
bool socket_options_called = false;
client.set_socket_options([&](socket_t) { socket_options_called = true; });
ASSERT_TRUE(client.connect());
ASSERT_TRUE(client.is_open());
EXPECT_TRUE(socket_options_called);
ASSERT_TRUE(client.send("hello"));
std::string msg;
auto result = client.read(msg);
EXPECT_EQ(result, ws::ReadResult::Text);
EXPECT_EQ(msg, "hello");
client.close();
}
TEST(WebSocketPreRoutingTest, RejectWithoutAuth) {
Server svr;