aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/chunked_handler.erl17
-rw-r--r--test/http_SUITE.erl9
2 files changed, 24 insertions, 2 deletions
diff --git a/test/chunked_handler.erl b/test/chunked_handler.erl
new file mode 100644
index 0000000..97ce27c
--- /dev/null
+++ b/test/chunked_handler.erl
@@ -0,0 +1,17 @@
+%% Feel free to use, reuse and abuse the code in this file.
+
+-module(chunked_handler).
+-behaviour(cowboy_http_handler).
+-export([init/3, handle/2, terminate/2]).
+
+init({_Transport, http}, Req, _Opts) ->
+ {ok, Req, undefined}.
+
+handle(Req, State) ->
+ {ok, Req2} = cowboy_http_req:chunked_reply(200, [], Req),
+ cowboy_http_req:chunk("chunked_handler\r\n", Req2),
+ cowboy_http_req:chunk("works fine!", Req2),
+ {ok, Req2, State}.
+
+terminate(_Req, _State) ->
+ ok.
diff --git a/test/http_SUITE.erl b/test/http_SUITE.erl
index 6b1a70f..b5b615d 100644
--- a/test/http_SUITE.erl
+++ b/test/http_SUITE.erl
@@ -18,7 +18,7 @@
-export([all/0, groups/0, init_per_suite/1, end_per_suite/1,
init_per_group/2, end_per_group/2]). %% ct.
--export([headers_dupe/1, headers_huge/1,
+-export([chunked_response/1, headers_dupe/1, headers_huge/1,
nc_rand/1, pipeline/1, raw/1]). %% http.
-export([http_200/1, http_404/1, websocket/1]). %% http and https.
@@ -29,7 +29,7 @@ all() ->
groups() ->
BaseTests = [http_200, http_404],
- [{http, [], [headers_dupe, headers_huge,
+ [{http, [], [chunked_response, headers_dupe, headers_huge,
nc_rand, pipeline, raw, websocket] ++ BaseTests},
{https, [], BaseTests}].
@@ -79,6 +79,7 @@ end_per_group(https, _Config) ->
init_http_dispatch() ->
[
{[<<"localhost">>], [
+ {[<<"chunked_response">>], chunked_handler, []},
{[<<"websocket">>], websocket_handler, []},
{[<<"headers">>, <<"dupe">>], http_handler,
[{headers, [{<<"Connection">>, <<"close">>}]}]},
@@ -91,6 +92,10 @@ init_https_dispatch() ->
%% http.
+chunked_response(Config) ->
+ {ok, {{"HTTP/1.1", 200, "OK"}, _Headers, "chunked_handler\r\nworks fine!"}} =
+ httpc:request(build_url("/chunked_response", Config)).
+
headers_dupe(Config) ->
{port, Port} = lists:keyfind(port, 1, Config),
{ok, Socket} = gen_tcp:connect("localhost", Port,