diff options
author | Loïc Hoguin <[email protected]> | 2013-09-02 19:14:28 +0200 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2013-09-02 19:14:28 +0200 |
commit | 9eab26d8353f1546ad8209196c36e42d616f952e (patch) | |
tree | 29dfd120a023582f6814b320ff75ac778a0ea49e /test | |
parent | d68b3de9d96dbe0fab56b78cdfeb699055446746 (diff) | |
download | cowboy-9eab26d8353f1546ad8209196c36e42d616f952e.tar.gz cowboy-9eab26d8353f1546ad8209196c36e42d616f952e.tar.bz2 cowboy-9eab26d8353f1546ad8209196c36e42d616f952e.zip |
Add request body support for SPDY
And various other improvements following the addition of two tests.
New dependency cowlib that will gradually receive most of the parse
code from SPDY but also HTTP and its headers.
Diffstat (limited to 'test')
-rw-r--r-- | test/spdy_SUITE.erl | 63 |
1 files changed, 62 insertions, 1 deletions
diff --git a/test/spdy_SUITE.erl b/test/spdy_SUITE.erl index 3cb32ce..6c19792 100644 --- a/test/spdy_SUITE.erl +++ b/test/spdy_SUITE.erl @@ -26,6 +26,8 @@ %% Tests. -export([check_status/1]). +-export([echo_body/1]). +-export([echo_body_multi/1]). %% ct. @@ -34,7 +36,9 @@ all() -> groups() -> [{spdy, [], [ - check_status + check_status, + echo_body, + echo_body_multi ]}]. init_per_suite(Config) -> @@ -82,6 +86,7 @@ init_dispatch(Config) -> {"/static/[...]", cowboy_static, [{directory, ?config(static_dir, Config)}, {mimetypes, [{<<".css">>, [<<"text/css">>]}]}]}, + {"/echo/body", http_echo_body, []}, {"/chunked", http_chunked, []}, {"/", http_handler, []} ]} @@ -120,3 +125,59 @@ check_status(Config) -> {Ret, IsFin, Host, Path} end || {Status, Fin, Host, Path} <- Tests], gun:close(Pid). + +echo_body(Config) -> + {_, Port} = lists:keyfind(port, 1, Config), + {ok, Pid} = gun:open("localhost", Port), + MRef = monitor(process, Pid), + Body = << 0:800000 >>, + StreamRef = gun:post(Pid, "/echo/body", [ + {<<"content-length">>, integer_to_list(byte_size(Body))}, + {<<"content-type">>, "application/octet-stream"} + ], Body), + receive + {'DOWN', MRef, _, _, Reason} -> + error(Reason); + {gun_response, Pid, StreamRef, nofin, << "200", _/bits >>, _} -> + ok + after 1000 -> + error(response_timeout) + end, + receive + {'DOWN', MRef, _, _, Reason2} -> + error({gun_data, Reason2}); + {gun_data, Pid, StreamRef, fin, Body} -> + ok + after 1000 -> + error(data_timeout) + end, + gun:close(Pid). + +echo_body_multi(Config) -> + {_, Port} = lists:keyfind(port, 1, Config), + {ok, Pid} = gun:open("localhost", Port), + MRef = monitor(process, Pid), + BodyChunk = << 0:80000 >>, + StreamRef = gun:post(Pid, "/echo/body", [ + {<<"content-length">>, integer_to_list(byte_size(BodyChunk) * 10)}, + {<<"content-type">>, "application/octet-stream"} + ]), + _ = [gun:data(Pid, StreamRef, nofin, BodyChunk) || _ <- lists:seq(1, 9)], + gun:data(Pid, StreamRef, fin, BodyChunk), + receive + {'DOWN', MRef, _, _, Reason} -> + error(Reason); + {gun_response, Pid, StreamRef, nofin, << "200", _/bits >>, _} -> + ok + after 1000 -> + error(response_timeout) + end, + receive + {'DOWN', MRef, _, _, Reason2} -> + error({gun_data, Reason2}); + {gun_data, Pid, StreamRef, fin, << 0:800000 >>} -> + ok + after 1000 -> + error(data_timeout) + end, + gun:close(Pid). |