aboutsummaryrefslogtreecommitdiffstats
path: root/test/http2_SUITE.erl
diff options
context:
space:
mode:
Diffstat (limited to 'test/http2_SUITE.erl')
-rw-r--r--test/http2_SUITE.erl30
1 files changed, 24 insertions, 6 deletions
diff --git a/test/http2_SUITE.erl b/test/http2_SUITE.erl
index 7730b58..8ffe2fd 100644
--- a/test/http2_SUITE.erl
+++ b/test/http2_SUITE.erl
@@ -18,6 +18,7 @@
-import(ct_helper, [config/2]).
-import(ct_helper, [doc/1]).
+-import(cowboy_test, [gun_open/1]).
all() -> [{group, clear}].
@@ -25,7 +26,8 @@ groups() -> [{clear, [parallel], ct_helper:all(?MODULE)}].
init_routes(_) -> [
{"localhost", [
- {"/", hello_h, []}
+ {"/", hello_h, []},
+ {"/resp_iolist_body", resp_iolist_body_h, []}
]}
].
@@ -45,16 +47,32 @@ do_handshake(Config) ->
inactivity_timeout(Config) ->
doc("Terminate when the inactivity timeout is reached"),
- Ref = inactivity_timeout_listener,
ProtoOpts = #{
env => #{dispatch => cowboy_router:compile(init_routes(Config))},
inactivity_timeout => 1000
},
- {ok, _} = cowboy:start_clear(Ref, [{port, 0}], ProtoOpts),
- Port = ranch:get_port(Ref),
- SocketConfig = [{type, tcp}, {protocol, http}, {port, Port}, {opts, []}|Config],
- {ok, Socket} = do_handshake(SocketConfig),
+ {ok, _} = cowboy:start_clear(inactivity_timeout, [{port, 0}], ProtoOpts),
+ Port = ranch:get_port(inactivity_timeout),
+ {ok, Socket} = do_handshake([{port, Port}|Config]),
receive after 1000 -> ok end,
%% Receive a GOAWAY frame back with an INTERNAL_ERROR.
{ok, << _:24, 7:8, _:72, 2:32 >>} = gen_tcp:recv(Socket, 17, 1000),
ok.
+
+resp_iolist_body(Config) ->
+ doc("Regression test when response bodies are iolists that "
+ "include improper lists, empty lists and empty binaries. "
+ "The original issue failed to split the body into frames properly."),
+ ProtoOpts = #{
+ env => #{dispatch => cowboy_router:compile(init_routes(Config))}
+ },
+ {ok, _} = cowboy:start_clear(resp_iolist_body, [{port, 0}], ProtoOpts),
+ Port = ranch:get_port(resp_iolist_body),
+ ConnPid = gun_open([{type, tcp}, {protocol, http2}, {port, Port}|Config]),
+ Ref = gun:get(ConnPid, "/resp_iolist_body"),
+ {response, nofin, 200, RespHeaders} = gun:await(ConnPid, Ref),
+ {_, BinLen} = lists:keyfind(<<"content-length">>, 1, RespHeaders),
+ Len = binary_to_integer(BinLen),
+ {ok, RespBody} = gun:await_body(ConnPid, Ref),
+ Len = iolist_size(RespBody),
+ gun:close(ConnPid).