mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-14 12:20:24 +00:00
Add ct tests for binary websocket frames
This commit is contained in:
parent
9800348c21
commit
7a68a38e5a
2 changed files with 12 additions and 0 deletions
|
@ -23,6 +23,8 @@ websocket_init(_TransportName, Req, _Opts) ->
|
|||
|
||||
websocket_handle({text, Data}, Req, State) ->
|
||||
{reply, {text, Data}, Req, State};
|
||||
websocket_handle({binary, Data}, Req, State) ->
|
||||
{reply, {binary, Data}, Req, State};
|
||||
websocket_handle(_Frame, Req, State) ->
|
||||
{ok, Req, State}.
|
||||
|
||||
|
|
|
@ -281,10 +281,20 @@ ws13(Config) ->
|
|||
{'Upgrade', "websocket"} = lists:keyfind('Upgrade', 1, Headers),
|
||||
{"sec-websocket-accept", "s3pPLMBiTxaQ9kYGzzhZRbK+xOo="}
|
||||
= lists:keyfind("sec-websocket-accept", 1, Headers),
|
||||
%% text
|
||||
ok = gen_tcp:send(Socket, << 16#81, 16#85, 16#37, 16#fa, 16#21, 16#3d,
|
||||
16#7f, 16#9f, 16#4d, 16#51, 16#58 >>),
|
||||
{ok, << 1:1, 0:3, 1:4, 0:1, 5:7, "Hello" >>}
|
||||
= gen_tcp:recv(Socket, 0, 6000),
|
||||
%% binary (empty)
|
||||
ok = gen_tcp:send(Socket, << 1:1, 0:3, 2:4, 0:8 >>),
|
||||
{ok, << 1:1, 0:3, 2:4, 0:8 >>} = gen_tcp:recv(Socket, 0, 6000),
|
||||
%% binary
|
||||
ok = gen_tcp:send(Socket, << 16#82, 16#85, 16#37, 16#fa, 16#21, 16#3d,
|
||||
16#7f, 16#9f, 16#4d, 16#51, 16#58 >>),
|
||||
{ok, << 1:1, 0:3, 2:4, 0:1, 5:7, "Hello" >>}
|
||||
= gen_tcp:recv(Socket, 0, 6000),
|
||||
%% Receives.
|
||||
{ok, << 1:1, 0:3, 1:4, 0:1, 14:7, "websocket_init" >>}
|
||||
= gen_tcp:recv(Socket, 0, 6000),
|
||||
{ok, << 1:1, 0:3, 1:4, 0:1, 16:7, "websocket_handle" >>}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue