diff options
author | Thomas Arts <[email protected]> | 2025-08-28 07:49:07 +0200 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2025-09-17 15:10:16 +0200 |
commit | b7b5dc929dd5908e38b1a1df9e9dc4df1e485f2b (patch) | |
tree | 448c1b7347aa013c8faf6c0424f5735433ebd887 /test | |
parent | 833764ea4cffe3327a4a4472264e3ae6f44a9b2a (diff) | |
download | cowboy-b7b5dc929dd5908e38b1a1df9e9dc4df1e485f2b.tar.gz cowboy-b7b5dc929dd5908e38b1a1df9e9dc4df1e485f2b.tar.bz2 cowboy-b7b5dc929dd5908e38b1a1df9e9dc4df1e485f2b.zip |
cowboy_rest: Allow last_modified to return undefined
Diffstat (limited to 'test')
-rw-r--r-- | test/handlers/last_modified_h.erl | 2 | ||||
-rw-r--r-- | test/rest_handler_SUITE.erl | 10 |
2 files changed, 12 insertions, 0 deletions
diff --git a/test/handlers/last_modified_h.erl b/test/handlers/last_modified_h.erl index 82893b3..1b109e3 100644 --- a/test/handlers/last_modified_h.erl +++ b/test/handlers/last_modified_h.erl @@ -19,6 +19,8 @@ get_text_plain(Req, State) -> last_modified(Req=#{qs := <<"tuple">>}, State) -> {{{2012, 9, 21}, {22, 36, 14}}, Req, State}; +last_modified(Req=#{qs := <<"undefined">>}, State) -> + {undefined, Req, State}; %% Simulate the callback being missing in other cases. last_modified(#{qs := <<"missing">>}, _) -> no_call. diff --git a/test/rest_handler_SUITE.erl b/test/rest_handler_SUITE.erl index a3d9533..7a9566f 100644 --- a/test/rest_handler_SUITE.erl +++ b/test/rest_handler_SUITE.erl @@ -796,6 +796,16 @@ last_modified_missing(Config) -> false = lists:keyfind(<<"last-modified">>, 1, Headers), ok. +last_modified_undefined(Config) -> + doc("The last-modified header must not be sent when the callback returns undefined."), + ConnPid = gun_open(Config), + Ref = gun:get(ConnPid, "/last_modified?undefined", [ + {<<"accept-encoding">>, <<"gzip">>} + ]), + {response, _, 200, Headers} = gun:await(ConnPid, Ref), + false = lists:keyfind(<<"last-modified">>, 1, Headers), + ok. + options_missing(Config) -> doc("A successful OPTIONS request to a simple handler results in " "a 200 OK response with the allow header set. (RFC7231 4.3.7)"), |