aboutsummaryrefslogtreecommitdiffstats
path: root/test/ws_SUITE.erl
diff options
context:
space:
mode:
Diffstat (limited to 'test/ws_SUITE.erl')
-rw-r--r--test/ws_SUITE.erl17
1 files changed, 15 insertions, 2 deletions
diff --git a/test/ws_SUITE.erl b/test/ws_SUITE.erl
index 9abeaca..3b74339 100644
--- a/test/ws_SUITE.erl
+++ b/test/ws_SUITE.erl
@@ -1,4 +1,4 @@
-%% Copyright (c) 2011-2017, Loïc Hoguin <[email protected]>
+%% Copyright (c) 2011-2024, Loïc Hoguin <[email protected]>
%%
%% Permission to use, copy, modify, and/or distribute this software for any
%% purpose with or without fee is hereby granted, provided that the above
@@ -68,7 +68,8 @@ init_dispatch() ->
{"/ws_timeout_cancel", ws_timeout_cancel, []},
{"/ws_max_frame_size", ws_max_frame_size, []},
{"/ws_deflate_opts", ws_deflate_opts_h, []},
- {"/ws_dont_validate_utf8", ws_dont_validate_utf8_h, []}
+ {"/ws_dont_validate_utf8", ws_dont_validate_utf8_h, []},
+ {"/ws_ping", ws_ping_h, []}
]}
]).
@@ -341,6 +342,7 @@ ws_first_frame_with_handshake(Config) ->
{ok, <<1:1, 0:3, 1:4, 0:1, 5:7, "Hello">>} = gen_tcp:recv(Socket, 0, 6000),
ok.
+%% @todo Move these tests to ws_handler_SUITE.
ws_init_return_ok(Config) ->
doc("Handler does nothing."),
{ok, Socket, _} = do_handshake("/ws_init?ok", Config),
@@ -471,6 +473,17 @@ ws_max_frame_size_intermediate_fragment_close(Config) ->
{error, closed} = gen_tcp:recv(Socket, 0, 6000),
ok.
+ws_ping(Config) ->
+ doc("Server initiated pings can receive a pong in response."),
+ {ok, Socket, _} = do_handshake("/ws_ping", Config),
+ %% Receive a server-sent ping.
+ {ok, << 1:1, 0:3, 9:4, 0:1, 0:7 >>} = gen_tcp:recv(Socket, 0, 6000),
+ %% Send a pong back with a 0 mask.
+ ok = gen_tcp:send(Socket, << 1:1, 0:3, 10:4, 1:1, 0:7, 0:32 >>),
+ %% Receive a text frame as a result.
+ {ok, << 1:1, 0:3, 1:4, 0:1, 4:7, "OK!!" >>} = gen_tcp:recv(Socket, 0, 6000),
+ ok.
+
ws_send_close(Config) ->
doc("Server-initiated close frame ends the connection."),
{ok, Socket, _} = do_handshake("/ws_send_close", Config),