aboutsummaryrefslogtreecommitdiffstats
path: root/test/handlers/resp_h.erl
diff options
context:
space:
mode:
Diffstat (limited to 'test/handlers/resp_h.erl')
-rw-r--r--test/handlers/resp_h.erl44
1 files changed, 25 insertions, 19 deletions
diff --git a/test/handlers/resp_h.erl b/test/handlers/resp_h.erl
index 97423c0..658c5f8 100644
--- a/test/handlers/resp_h.erl
+++ b/test/handlers/resp_h.erl
@@ -26,28 +26,34 @@ do(<<"set_resp_header">>, Req0, Opts) ->
Req = cowboy_req:set_resp_header(<<"content-type">>, <<"text/plain">>, Req0),
{ok, cowboy_req:reply(200, #{}, "OK", Req), Opts};
do(<<"set_resp_headers">>, Req0, Opts) ->
- Req = cowboy_req:set_resp_headers(#{<<"x-header-test1">> => <<"test1">>, <<"x-header-test2">> => <<"test2">>}, Req0),
+ Req = cowboy_req:set_resp_headers(#{
+ <<"content-type">> => <<"text/plain">>,
+ <<"content-encoding">> => <<"gzip">>
+ }, Req0),
{ok, cowboy_req:reply(200, #{}, "OK", Req), Opts};
-do(<<"resp_headers">>, Req0, Opts) ->
- Req1 = cowboy_req:set_resp_header(<<"x-header-test1">>, <<"test1">>, Req0),
- Req2 = cowboy_req:set_resp_headers(#{<<"x-header-test2">> => <<"test2">>, <<"x-header-test3">> => <<"test3">>}, Req1),
- Headers = cowboy_req:resp_headers(Req2),
- true = maps:is_key(<<"x-header-test1">>, Headers),
- true = maps:is_key(<<"x-header-test2">>, Headers),
- true = maps:is_key(<<"x-header-test3">>, Headers),
- {ok, cowboy_req:reply(200, #{}, "OK", Req2), Opts};
do(<<"resp_header_defined">>, Req0, Opts) ->
- Req1 = cowboy_req:set_resp_header(<<"x-header-test1">>, <<"test1">>, Req0),
- <<"test1">> = cowboy_req:resp_header(<<"x-header-test1">>, Req1),
- <<"test1">> = cowboy_req:resp_header(<<"x-header-test1">>, Req1, foo),
- {ok, cowboy_req:reply(200, #{}, "OK", Req0), Opts};
-do(<<"resp_header_default">>, Req0, Opts) ->
- undefined = cowboy_req:resp_header(<<"x-header-test1">>, Req0),
- <<"ok">> = cowboy_req:resp_header(<<"x-header-test1">>, Req0, <<"ok">>),
- {ok, cowboy_req:reply(200, #{}, "OK", Req0), Opts};
-do(<<"resp_headers_empty">>, Req0, Opts) ->
- #{} = cowboy_req:resp_headers(Req0),
+ Req1 = cowboy_req:set_resp_header(<<"content-type">>, <<"text/plain">>, Req0),
+ <<"text/plain">> = cowboy_req:resp_header(<<"content-type">>, Req1),
+ <<"text/plain">> = cowboy_req:resp_header(<<"content-type">>, Req1, default),
{ok, cowboy_req:reply(200, #{}, "OK", Req0), Opts};
+do(<<"resp_header_default">>, Req, Opts) ->
+ undefined = cowboy_req:resp_header(<<"content-type">>, Req),
+ default = cowboy_req:resp_header(<<"content-type">>, Req, default),
+ {ok, cowboy_req:reply(200, #{}, "OK", Req), Opts};
+do(<<"resp_headers">>, Req0, Opts) ->
+ Req1 = cowboy_req:set_resp_header(<<"server">>, <<"nginx">>, Req0),
+ Req = cowboy_req:set_resp_headers(#{
+ <<"content-type">> => <<"text/plain">>,
+ <<"content-encoding">> => <<"gzip">>
+ }, Req1),
+ Headers = cowboy_req:resp_headers(Req),
+ true = maps:is_key(<<"server">>, Headers),
+ true = maps:is_key(<<"content-type">>, Headers),
+ true = maps:is_key(<<"content-encoding">>, Headers),
+ {ok, cowboy_req:reply(200, #{}, "OK", Req), Opts};
+do(<<"resp_headers_empty">>, Req, Opts) ->
+ #{} = cowboy_req:resp_headers(Req),
+ {ok, cowboy_req:reply(200, #{}, "OK", Req), Opts};
do(<<"set_resp_body">>, Req0, Opts) ->
Arg = cowboy_req:binding(arg, Req0),
Req1 = case Arg of