aboutsummaryrefslogtreecommitdiffstats
path: root/test/static_handler_SUITE.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2017-02-05 13:45:35 +0100
committerLoïc Hoguin <[email protected]>2017-02-05 13:45:35 +0100
commit4cbdfdd293c687212f9ce64e608de838ec74a592 (patch)
tree8ac66c32edee0feb70c60f4a6d67842f88961fd4 /test/static_handler_SUITE.erl
parentf4fddbd0a1f91f8bd71701fe4c50dd3962b97207 (diff)
downloadcowboy-4cbdfdd293c687212f9ce64e608de838ec74a592.tar.gz
cowboy-4cbdfdd293c687212f9ce64e608de838ec74a592.tar.bz2
cowboy-4cbdfdd293c687212f9ce64e608de838ec74a592.zip
Fix sending of large files with HTTP/2
Also finish implementing the relevant test, getting rid of todos.
Diffstat (limited to 'test/static_handler_SUITE.erl')
-rw-r--r--test/static_handler_SUITE.erl31
1 files changed, 24 insertions, 7 deletions
diff --git a/test/static_handler_SUITE.erl b/test/static_handler_SUITE.erl
index 7a6517f..95d6d75 100644
--- a/test/static_handler_SUITE.erl
+++ b/test/static_handler_SUITE.erl
@@ -391,13 +391,30 @@ dir_html(Config) ->
{_, <<"text/html">>} = lists:keyfind(<<"content-type">>, 1, Headers),
ok.
-%% @todo This test results in a crash dump.
-%dir_large_file(Config) ->
-% doc("Get a large file."),
-% {200, Headers, _} = do_get(config(prefix, Config) ++ "/large.bin", Config),
-% {_, <<"text/html">>} = lists:keyfind(<<"content-type">>, 1, Headers),
-%% @todo Receive body.
-% ok.
+dir_large_file(Config) ->
+ doc("Get a large file."),
+ ConnPid = gun_open(Config),
+ Ref = gun:get(ConnPid, config(prefix, Config) ++ "/large.bin",
+ [{<<"accept-encoding">>, <<"gzip">>}]),
+ {response, nofin, 200, RespHeaders} = gun:await(ConnPid, Ref),
+ {_, <<"application/octet-stream">>} = lists:keyfind(<<"content-type">>, 1, RespHeaders),
+ Size = 512*1024*1024,
+ {ok, Size} = do_dir_large_file(ConnPid, Ref, 0),
+ ok.
+
+do_dir_large_file(ConnPid, Ref, N) ->
+ receive
+ {gun_data, ConnPid, Ref, nofin, Data} ->
+ do_dir_large_file(ConnPid, Ref, N + byte_size(Data));
+ {gun_data, ConnPid, Ref, fin, Data} ->
+ {ok, N + byte_size(Data)};
+ {gun_error, ConnPid, Ref, Reason} ->
+ {error, Reason};
+ {gun_error, ConnPid, Reason} ->
+ {error, Reason}
+ after 5000 ->
+ {error, timeout}
+ end.
dir_text(Config) ->
doc("Get a .txt file. The extension is unknown by default."),