diff options
Diffstat (limited to 'test/http_SUITE_data')
-rw-r--r-- | test/http_SUITE_data/http_body_qs.erl | 12 | ||||
-rw-r--r-- | test/http_SUITE_data/http_echo_body.erl | 6 | ||||
-rw-r--r-- | test/http_SUITE_data/http_errors.erl | 2 | ||||
-rw-r--r-- | test/http_SUITE_data/http_handler.erl | 2 | ||||
-rw-r--r-- | test/http_SUITE_data/http_multipart.erl | 2 | ||||
-rw-r--r-- | test/http_SUITE_data/http_req_attr.erl | 2 | ||||
-rw-r--r-- | test/http_SUITE_data/http_set_resp.erl | 4 | ||||
-rw-r--r-- | test/http_SUITE_data/http_stream_body.erl | 16 | ||||
-rw-r--r-- | test/http_SUITE_data/rest_param_all.erl | 2 | ||||
-rw-r--r-- | test/http_SUITE_data/rest_patch_resource.erl | 2 |
10 files changed, 28 insertions, 22 deletions
diff --git a/test/http_SUITE_data/http_body_qs.erl b/test/http_SUITE_data/http_body_qs.erl index 945b7fd..e0673cf 100644 --- a/test/http_SUITE_data/http_body_qs.erl +++ b/test/http_SUITE_data/http_body_qs.erl @@ -17,16 +17,16 @@ maybe_echo(<<"POST">>, true, Req) -> echo(proplists:get_value(<<"echo">>, PostVals), Req2) end; maybe_echo(<<"POST">>, false, Req) -> - cowboy_req:reply(400, [], <<"Missing body.">>, Req); + cowboy_req:reply(400, #{}, <<"Missing body.">>, Req); maybe_echo(_, _, Req) -> %% Method not allowed. cowboy_req:reply(405, Req). echo(badlength, Req) -> - cowboy_req:reply(413, [], <<"POST body bigger than 16000 bytes">>, Req); + cowboy_req:reply(413, #{}, <<"POST body bigger than 16000 bytes">>, Req); echo(undefined, Req) -> - cowboy_req:reply(400, [], <<"Missing echo parameter.">>, Req); + cowboy_req:reply(400, #{}, <<"Missing echo parameter.">>, Req); echo(Echo, Req) -> - cowboy_req:reply(200, [ - {<<"content-type">>, <<"text/plain; charset=utf-8">>} - ], Echo, Req). + cowboy_req:reply(200, #{ + <<"content-type">> => <<"text/plain; charset=utf-8">> + }, Echo, Req). diff --git a/test/http_SUITE_data/http_echo_body.erl b/test/http_SUITE_data/http_echo_body.erl index c76b9b3..a541a67 100644 --- a/test/http_SUITE_data/http_echo_body.erl +++ b/test/http_SUITE_data/http_echo_body.erl @@ -6,16 +6,16 @@ init(Req, Opts) -> true = cowboy_req:has_body(Req), - Req3 = case cowboy_req:body(Req, [{length, 1000000}]) of + Req3 = case cowboy_req:read_body(Req, [{length, 1000000}]) of {ok, Body, Req2} -> handle_body(Req2, Body); {more, _, Req2} -> handle_badlength(Req2) end, {ok, Req3, Opts}. handle_badlength(Req) -> - cowboy_req:reply(413, [], <<"Request entity too large">>, Req). + cowboy_req:reply(413, #{}, <<"Request entity too large">>, Req). handle_body(Req, Body) -> Size = cowboy_req:body_length(Req), Size = byte_size(Body), - cowboy_req:reply(200, [], Body, Req). + cowboy_req:reply(200, #{}, Body, Req). diff --git a/test/http_SUITE_data/http_errors.erl b/test/http_SUITE_data/http_errors.erl index ee5c2b2..14e3d09 100644 --- a/test/http_SUITE_data/http_errors.erl +++ b/test/http_SUITE_data/http_errors.erl @@ -13,5 +13,5 @@ case_init(<<"init_before_reply">> = Case, _Req) -> error(Case); case_init(<<"init_after_reply">> = Case, Req) -> ct_helper_error_h:ignore(?MODULE, case_init, 2), - _ = cowboy_req:reply(200, [], "http_handler_crashes", Req), + _ = cowboy_req:reply(200, #{}, "http_handler_crashes", Req), error(Case). diff --git a/test/http_SUITE_data/http_handler.erl b/test/http_SUITE_data/http_handler.erl index 62e9193..eb31aa8 100644 --- a/test/http_SUITE_data/http_handler.erl +++ b/test/http_SUITE_data/http_handler.erl @@ -5,6 +5,6 @@ -export([init/2]). init(Req, Opts) -> - Headers = proplists:get_value(headers, Opts, []), + Headers = proplists:get_value(headers, Opts, #{}), Body = proplists:get_value(body, Opts, "http_handler"), {ok, cowboy_req:reply(200, Headers, Body, Req), Opts}. diff --git a/test/http_SUITE_data/http_multipart.erl b/test/http_SUITE_data/http_multipart.erl index 196cbce..212f569 100644 --- a/test/http_SUITE_data/http_multipart.erl +++ b/test/http_SUITE_data/http_multipart.erl @@ -6,7 +6,7 @@ init(Req, Opts) -> {Result, Req2} = acc_multipart(Req, []), - {ok, cowboy_req:reply(200, [], term_to_binary(Result), Req2), Opts}. + {ok, cowboy_req:reply(200, #{}, term_to_binary(Result), Req2), Opts}. acc_multipart(Req, Acc) -> case cowboy_req:part(Req) of diff --git a/test/http_SUITE_data/http_req_attr.erl b/test/http_SUITE_data/http_req_attr.erl index d8483a5..c6a940e 100644 --- a/test/http_SUITE_data/http_req_attr.erl +++ b/test/http_SUITE_data/http_req_attr.erl @@ -12,4 +12,4 @@ init(Req, Opts) -> Host = cowboy_req:host(Req), Port = cowboy_req:port(Req), Value = [Host, "\n", integer_to_list(Port)], - {ok, cowboy_req:reply(200, [], Value, Req), Opts}. + {ok, cowboy_req:reply(200, #{}, Value, Req), Opts}. diff --git a/test/http_SUITE_data/http_set_resp.erl b/test/http_SUITE_data/http_set_resp.erl index 2e7f835..6ac4c8e 100644 --- a/test/http_SUITE_data/http_set_resp.erl +++ b/test/http_SUITE_data/http_set_resp.erl @@ -5,11 +5,11 @@ -export([init/2]). init(Req, Opts) -> - Headers = proplists:get_value(headers, Opts, []), + Headers = proplists:get_value(headers, Opts, #{}), Body = proplists:get_value(body, Opts, <<"http_handler_set_resp">>), Req2 = lists:foldl(fun({Name, Value}, R) -> cowboy_req:set_resp_header(Name, Value, R) - end, Req, Headers), + end, Req, maps:to_list(Headers)), Req3 = cowboy_req:set_resp_body(Body, Req2), Req4 = cowboy_req:set_resp_header(<<"x-cowboy-test">>, <<"ok">>, Req3), Req5 = cowboy_req:set_resp_cookie(<<"cake">>, <<"lie">>, [], Req4), diff --git a/test/http_SUITE_data/http_stream_body.erl b/test/http_SUITE_data/http_stream_body.erl index aea5300..ef10266 100644 --- a/test/http_SUITE_data/http_stream_body.erl +++ b/test/http_SUITE_data/http_stream_body.erl @@ -7,16 +7,22 @@ init(Req, Opts) -> Body = proplists:get_value(body, Opts, "http_handler_stream_body"), Reply = proplists:get_value(reply, Opts), - SFun = fun(Socket, Transport) -> Transport:send(Socket, Body) end, + SFun = fun () -> + cowboy_req:send_body(Body, nofin, Req) + end, Req2 = case Reply of set_resp -> SLen = iolist_size(Body), - cowboy_req:set_resp_body_fun(SLen, SFun, Req); + cowboy_req:set_resp_body({stream, SLen, SFun}, Req); + %% @todo Hmm that one will be sent as chunked now. + %% We need an option to disable chunked. set_resp_close -> - cowboy_req:set_resp_body_fun(SFun, Req); + cowboy_req:set_resp_body({stream, undefined, SFun}, Req); set_resp_chunked -> %% Here Body should be a list of chunks, not a binary. - SFun2 = fun(SendFun) -> lists:foreach(SendFun, Body) end, - cowboy_req:set_resp_body_fun(chunked, SFun2, Req) + SFun2 = fun () -> + lists:foreach(fun (Data) -> cowboy_req:send_body(Data, nofin, Req) end, Body) + end, + cowboy_req:set_resp_body({stream, undefined, SFun2}, Req) end, {ok, cowboy_req:reply(200, Req2), Opts}. diff --git a/test/http_SUITE_data/rest_param_all.erl b/test/http_SUITE_data/rest_param_all.erl index 2b2ea23..d74df74 100644 --- a/test/http_SUITE_data/rest_param_all.erl +++ b/test/http_SUITE_data/rest_param_all.erl @@ -17,7 +17,7 @@ content_types_provided(Req, State) -> {[{{<<"text">>, <<"plain">>, '*'}, get_text_plain}], Req, State}. get_text_plain(Req, State) -> - {_, _, Param} = cowboy_req:meta(media_type, Req, {{<<"text">>, <<"plain">>}, []}), + {_, _, Param} = maps:get(media_type, Req, {{<<"text">>, <<"plain">>}, []}), Body = if Param == '*' -> <<"'*'">>; diff --git a/test/http_SUITE_data/rest_patch_resource.erl b/test/http_SUITE_data/rest_patch_resource.erl index c1244e7..341920d 100644 --- a/test/http_SUITE_data/rest_patch_resource.erl +++ b/test/http_SUITE_data/rest_patch_resource.erl @@ -28,7 +28,7 @@ content_types_accepted(Req, State) -> end. patch_text_plain(Req, State) -> - case cowboy_req:body(Req) of + case cowboy_req:read_body(Req) of {ok, <<"stop">>, Req0} -> {stop, cowboy_req:reply(400, Req0), State}; {ok, <<"false">>, Req0} -> |