diff options
author | Loïc Hoguin <[email protected]> | 2018-01-22 14:00:05 +0100 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2018-01-22 14:00:05 +0100 |
commit | 3a7b411143db08cb4d8813d00988c07848738bd3 (patch) | |
tree | b30a00bb1b06d3f784e4be867a1b6e7f088ffb70 /test/handlers/resp_h.erl | |
parent | 82cd22a88b3f87064d9f17e36652b104b709a679 (diff) | |
download | cowboy-3a7b411143db08cb4d8813d00988c07848738bd3.tar.gz cowboy-3a7b411143db08cb4d8813d00988c07848738bd3.tar.bz2 cowboy-3a7b411143db08cb4d8813d00988c07848738bd3.zip |
Don't crash in delete_resp_header if no resp headers are set
Diffstat (limited to 'test/handlers/resp_h.erl')
-rw-r--r-- | test/handlers/resp_h.erl | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/test/handlers/resp_h.erl b/test/handlers/resp_h.erl index ba46213..487a724 100644 --- a/test/handlers/resp_h.erl +++ b/test/handlers/resp_h.erl @@ -94,10 +94,13 @@ do(<<"has_resp_body">>, Req0, Opts) -> {ok, cowboy_req:reply(200, #{}, Req), Opts} end; do(<<"delete_resp_header">>, Req0, Opts) -> - false = cowboy_req:has_resp_header(<<"content-type">>, Req0), - Req1 = cowboy_req:set_resp_header(<<"content-type">>, <<"text/plain">>, Req0), - true = cowboy_req:has_resp_header(<<"content-type">>, Req1), - Req = cowboy_req:delete_resp_header(<<"content-type">>, Req1), + %% We try to delete first even though it hasn't been set to + %% make sure this noop is possible. + Req1 = cowboy_req:delete_resp_header(<<"content-type">>, Req0), + false = cowboy_req:has_resp_header(<<"content-type">>, Req1), + Req2 = cowboy_req:set_resp_header(<<"content-type">>, <<"text/plain">>, Req1), + true = cowboy_req:has_resp_header(<<"content-type">>, Req2), + Req = cowboy_req:delete_resp_header(<<"content-type">>, Req2), false = cowboy_req:has_resp_header(<<"content-type">>, Req), {ok, cowboy_req:reply(200, #{}, "OK", Req), Opts}; do(<<"inform2">>, Req0, Opts) -> |