aboutsummaryrefslogtreecommitdiffstats
path: root/test/http_SUITE.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2011-10-20 01:28:50 +0200
committerLoïc Hoguin <[email protected]>2011-10-20 01:36:23 +0200
commit70d28ff64d107eb04903779573a4c6b4df18fdfa (patch)
treedc15d03a1061e9fa1de77393b9f750fcf38cdf86 /test/http_SUITE.erl
parentfe5f0ca539fe883f397c97a5793f86e2de4a34f3 (diff)
downloadcowboy-70d28ff64d107eb04903779573a4c6b4df18fdfa.tar.gz
cowboy-70d28ff64d107eb04903779573a4c6b4df18fdfa.tar.bz2
cowboy-70d28ff64d107eb04903779573a4c6b4df18fdfa.zip
Make sure the hixie-76 websocket code works properly with proxies
Diffstat (limited to 'test/http_SUITE.erl')
-rw-r--r--test/http_SUITE.erl12
1 files changed, 9 insertions, 3 deletions
diff --git a/test/http_SUITE.erl b/test/http_SUITE.erl
index b5ee98b..de1045a 100644
--- a/test/http_SUITE.erl
+++ b/test/http_SUITE.erl
@@ -243,11 +243,15 @@ raw(Config) ->
[{Packet, StatusCode} = raw_req(Packet, Config)
|| {Packet, StatusCode} <- Tests].
+%% This test makes sure the code works even if we wait for a reply
+%% before sending the third challenge key in the GET body.
+%%
+%% This ensures that Cowboy will work fine with proxies on hixie.
ws0(Config) ->
{port, Port} = lists:keyfind(port, 1, Config),
{ok, Socket} = gen_tcp:connect("localhost", Port,
[binary, {active, false}, {packet, raw}]),
- ok = gen_tcp:send(Socket, [
+ ok = gen_tcp:send(Socket,
"GET /websocket HTTP/1.1\r\n"
"Host: localhost\r\n"
"Connection: Upgrade\r\n"
@@ -255,11 +259,11 @@ ws0(Config) ->
"Origin: http://localhost\r\n"
"Sec-Websocket-Key1: Y\" 4 1Lj!957b8@0H756!i\r\n"
"Sec-Websocket-Key2: 1711 M;4\\74 80<6\r\n"
- "\r\n", <<15,245,8,18,2,204,133,33>>]),
+ "\r\n"),
{ok, Handshake} = gen_tcp:recv(Socket, 0, 6000),
{ok, {http_response, {1, 1}, 101, "WebSocket Protocol Handshake"}, Rest}
= erlang:decode_packet(http, Handshake, []),
- [Headers, Body] = websocket_headers(
+ [Headers, <<>>] = websocket_headers(
erlang:decode_packet(httph, Rest, []), []),
{'Connection', "Upgrade"} = lists:keyfind('Connection', 1, Headers),
{'Upgrade', "WebSocket"} = lists:keyfind('Upgrade', 1, Headers),
@@ -267,6 +271,8 @@ ws0(Config) ->
= lists:keyfind("sec-websocket-location", 1, Headers),
{"sec-websocket-origin", "http://localhost"}
= lists:keyfind("sec-websocket-origin", 1, Headers),
+ ok = gen_tcp:send(Socket, <<15,245,8,18,2,204,133,33>>),
+ {ok, Body} = gen_tcp:recv(Socket, 0, 6000),
<<169,244,191,103,146,33,149,59,74,104,67,5,99,118,171,236>> = Body,
ok = gen_tcp:send(Socket, << 0, "client_msg", 255 >>),
{ok, << 0, "client_msg", 255 >>} = gen_tcp:recv(Socket, 0, 6000),