aboutsummaryrefslogtreecommitdiffstats
path: root/test/ws_SUITE.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2017-02-05 11:27:54 +0100
committerLoïc Hoguin <[email protected]>2017-02-05 11:27:54 +0100
commitf4fddbd0a1f91f8bd71701fe4c50dd3962b97207 (patch)
tree22e84fa4c7591642571cd6bb29f87e9d0c660c80 /test/ws_SUITE.erl
parentd8d7838a77cdb5c83e1994452122b5891db599cb (diff)
downloadcowboy-f4fddbd0a1f91f8bd71701fe4c50dd3962b97207.tar.gz
cowboy-f4fddbd0a1f91f8bd71701fe4c50dd3962b97207.tar.bz2
cowboy-f4fddbd0a1f91f8bd71701fe4c50dd3962b97207.zip
Test Websocket protocol version 7
A bit late but at least removes a todo.
Diffstat (limited to 'test/ws_SUITE.erl')
-rw-r--r--test/ws_SUITE.erl20
1 files changed, 19 insertions, 1 deletions
diff --git a/test/ws_SUITE.erl b/test/ws_SUITE.erl
index 937abb8..9f5cb0a 100644
--- a/test/ws_SUITE.erl
+++ b/test/ws_SUITE.erl
@@ -132,7 +132,25 @@ ws0(Config) ->
{ok, {http_response, {1, 1}, 400, _}, _} = erlang:decode_packet(http, Handshake, []),
ok.
-%% @todo What about version 7?
+ws7(Config) ->
+ doc("Websocket version 7 (draft) is supported."),
+ {ok, Socket} = gen_tcp:connect("localhost", config(port, Config), [binary, {active, false}]),
+ ok = gen_tcp:send(Socket, [
+ "GET /ws_echo_timer HTTP/1.1\r\n"
+ "Host: localhost\r\n"
+ "Connection: Upgrade\r\n"
+ "Upgrade: websocket\r\n"
+ "Sec-WebSocket-Origin: http://localhost\r\n"
+ "Sec-WebSocket-Version: 7\r\n"
+ "Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==\r\n"
+ "\r\n"]),
+ {ok, Handshake} = gen_tcp:recv(Socket, 0, 6000),
+ {ok, {http_response, {1, 1}, 101, _}, Rest} = erlang:decode_packet(http, Handshake, []),
+ [Headers, <<>>] = do_decode_headers(erlang:decode_packet(httph, Rest, []), []),
+ {_, "Upgrade"} = lists:keyfind('Connection', 1, Headers),
+ {_, "websocket"} = lists:keyfind('Upgrade', 1, Headers),
+ {_, "s3pPLMBiTxaQ9kYGzzhZRbK+xOo="} = lists:keyfind("sec-websocket-accept", 1, Headers),
+ do_ws_version(Socket).
ws8(Config) ->
doc("Websocket version 8 (draft) is supported."),