aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/http_SUITE.erl4
-rw-r--r--test/http_handler_multipart.erl22
-rw-r--r--test/http_handler_set_resp.erl12
-rw-r--r--test/http_handler_stream_body.erl2
4 files changed, 18 insertions, 22 deletions
diff --git a/test/http_SUITE.erl b/test/http_SUITE.erl
index 6bed436..1140cf9 100644
--- a/test/http_SUITE.erl
+++ b/test/http_SUITE.erl
@@ -599,9 +599,7 @@ onrequest_reply(Config) ->
onrequest_hook(Req) ->
case cowboy_req:qs_val(<<"reply">>, Req) of
{undefined, Req2} ->
- {ok, Req3} = cowboy_req:set_resp_header(
- 'Server', <<"Serenity">>, Req2),
- Req3;
+ cowboy_req:set_resp_header('Server', <<"Serenity">>, Req2);
{_, Req2} ->
{ok, Req3} = cowboy_req:reply(
200, [], <<"replied!">>, Req2),
diff --git a/test/http_handler_multipart.erl b/test/http_handler_multipart.erl
index ad5d27e..850574f 100644
--- a/test/http_handler_multipart.erl
+++ b/test/http_handler_multipart.erl
@@ -8,22 +8,22 @@ init({_Transport, http}, Req, []) ->
{ok, Req, {}}.
handle(Req, State) ->
- {Result, Req2} = acc_multipart(Req, []),
+ {Result, Req2} = acc_multipart(Req),
{ok, Req3} = cowboy_req:reply(200, [], term_to_binary(Result), Req2),
{ok, Req3, State}.
terminate(_Req, _State) ->
ok.
-acc_multipart(Req, Acc) ->
- {Result, Req2} = cowboy_req:multipart_data(Req),
- acc_multipart(Req2, Acc, Result).
+acc_multipart(Req) ->
+ acc_multipart(cowboy_req:multipart_data(Req), []).
-acc_multipart(Req, Acc, {headers, Headers}) ->
- acc_multipart(Req, [{Headers, []}|Acc]);
-acc_multipart(Req, [{Headers, BodyAcc}|Acc], {body, Data}) ->
- acc_multipart(Req, [{Headers, [Data|BodyAcc]}|Acc]);
-acc_multipart(Req, [{Headers, BodyAcc}|Acc], end_of_part) ->
- acc_multipart(Req, [{Headers, list_to_binary(lists:reverse(BodyAcc))}|Acc]);
-acc_multipart(Req, Acc, eof) ->
+acc_multipart({headers, Headers, Req}, Acc) ->
+ acc_multipart(cowboy_req:multipart_data(Req), [{Headers, []}|Acc]);
+acc_multipart({body, Data, Req}, [{Headers, BodyAcc}|Acc]) ->
+ acc_multipart(cowboy_req:multipart_data(Req), [{Headers, [Data|BodyAcc]}|Acc]);
+acc_multipart({end_of_part, Req}, [{Headers, BodyAcc}|Acc]) ->
+ acc_multipart(cowboy_req:multipart_data(Req),
+ [{Headers, list_to_binary(lists:reverse(BodyAcc))}|Acc]);
+acc_multipart({eof, Req}, Acc) ->
{lists:reverse(Acc), Req}.
diff --git a/test/http_handler_set_resp.erl b/test/http_handler_set_resp.erl
index db22168..806bca8 100644
--- a/test/http_handler_set_resp.erl
+++ b/test/http_handler_set_resp.erl
@@ -7,14 +7,12 @@
init({_Transport, http}, Req, Opts) ->
Headers = proplists:get_value(headers, Opts, []),
Body = proplists:get_value(body, Opts, <<"http_handler_set_resp">>),
- {ok, Req2} = lists:foldl(fun({Name, Value}, {ok, R}) ->
+ Req2 = lists:foldl(fun({Name, Value}, R) ->
cowboy_req:set_resp_header(Name, Value, R)
- end, {ok, Req}, Headers),
- {ok, Req3} = cowboy_req:set_resp_body(Body, Req2),
- {ok, Req4} = cowboy_req:set_resp_header(
- <<"X-Cowboy-Test">>, <<"ok">>, Req3),
- {ok, Req5} = cowboy_req:set_resp_cookie(
- <<"cake">>, <<"lie">>, [], Req4),
+ end, Req, 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),
{ok, Req5, undefined}.
handle(Req, State) ->
diff --git a/test/http_handler_stream_body.erl b/test/http_handler_stream_body.erl
index 13221eb..feb4f78 100644
--- a/test/http_handler_stream_body.erl
+++ b/test/http_handler_stream_body.erl
@@ -16,7 +16,7 @@ handle(Req, State=#state{headers=_Headers, body=Body, reply=set_resp}) ->
{ok, Transport, Socket} = cowboy_req:transport(Req),
SFun = fun() -> Transport:send(Socket, Body), sent end,
SLen = iolist_size(Body),
- {ok, Req2} = cowboy_req:set_resp_body_fun(SLen, SFun, Req),
+ Req2 = cowboy_req:set_resp_body_fun(SLen, SFun, Req),
{ok, Req3} = cowboy_req:reply(200, Req2),
{ok, Req3, State}.