aboutsummaryrefslogtreecommitdiffstats
path: root/test/spdy_SUITE.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2014-07-07 17:18:14 +0200
committerLoïc Hoguin <[email protected]>2014-07-07 17:18:14 +0200
commit7f179f377fcfacb1a70375a5f541e625f6ed34f2 (patch)
tree29e86adc67c7cc53468cd0094dc609445ae8a6cf /test/spdy_SUITE.erl
parentd38c064f732a7c98f0332a8ee7bb524a25a21285 (diff)
downloadcowboy-7f179f377fcfacb1a70375a5f541e625f6ed34f2.tar.gz
cowboy-7f179f377fcfacb1a70375a5f541e625f6ed34f2.tar.bz2
cowboy-7f179f377fcfacb1a70375a5f541e625f6ed34f2.zip
Add failing test of chaining SPDY frames
Diffstat (limited to 'test/spdy_SUITE.erl')
-rw-r--r--test/spdy_SUITE.erl37
1 files changed, 37 insertions, 0 deletions
diff --git a/test/spdy_SUITE.erl b/test/spdy_SUITE.erl
index 2e9c7e4..400e147 100644
--- a/test/spdy_SUITE.erl
+++ b/test/spdy_SUITE.erl
@@ -17,6 +17,8 @@
-import(cowboy_test, [config/2]).
-import(cowboy_test, [gun_monitor_open/1]).
+-import(cowboy_test, [raw_open/1]).
+-import(cowboy_test, [raw_send/2]).
%% ct.
@@ -108,3 +110,38 @@ echo_body_multi(Config) ->
{response, nofin, 200, _} = gun:await(ConnPid, StreamRef, MRef),
{ok, << 0:800000 >>} = gun:await_body(ConnPid, StreamRef, MRef),
gun:close(ConnPid).
+
+two_frames_one_packet(Config) ->
+ {raw_client, Socket, Transport} = Client = raw_open([
+ {opts, [{client_preferred_next_protocols,
+ {client, [<<"spdy/3">>], <<"spdy/3">>}}]}
+ |Config]),
+ Zdef = cow_spdy:deflate_init(),
+ Zinf = cow_spdy:inflate_init(),
+ ok = raw_send(Client, iolist_to_binary([
+ cow_spdy:syn_stream(Zdef, 1, 0, true, false,
+ 0, <<"GET">>, <<"https">>, <<"localhost">>,
+ <<"/">>, <<"HTTP/1.1">>, []),
+ cow_spdy:syn_stream(Zdef, 3, 0, true, false,
+ 0, <<"GET">>, <<"https">>, <<"localhost">>,
+ <<"/">>, <<"HTTP/1.1">>, [])
+ ])),
+ {Frame1, Rest1} = spdy_recv(Socket, Transport, <<>>),
+ {syn_reply, 1, false, <<"200 OK">>, _, _} = cow_spdy:parse(Frame1, Zinf),
+ {Frame2, Rest2} = spdy_recv(Socket, Transport, Rest1),
+ {data, 1, true, _} = cow_spdy:parse(Frame2, Zinf),
+ {Frame3, Rest3} = spdy_recv(Socket, Transport, Rest2),
+ {syn_reply, 3, false, <<"200 OK">>, _, _} = cow_spdy:parse(Frame3, Zinf),
+ {Frame4, <<>>} = spdy_recv(Socket, Transport, Rest3),
+ {data, 3, true, _} = cow_spdy:parse(Frame4, Zinf),
+ ok.
+
+spdy_recv(Socket, Transport, Acc) ->
+ {ok, Data} = Transport:recv(Socket, 0, 5000),
+ Data2 = << Acc/binary, Data/bits >>,
+ case cow_spdy:split(Data2) of
+ false ->
+ spdy_recv(Socket, Transport, Data2);
+ {true, Frame, Rest} ->
+ {Frame, Rest}
+ end.