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 /src | |
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 'src')
-rw-r--r-- | src/cowboy_rest.erl | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/cowboy_rest.erl b/src/cowboy_rest.erl index 9f30fcf..7629b3e 100644 --- a/src/cowboy_rest.erl +++ b/src/cowboy_rest.erl @@ -130,7 +130,7 @@ -optional_callbacks([languages_provided/2]). -callback last_modified(Req, State) - -> {calendar:datetime(), Req, State} + -> {calendar:datetime() | undefined, Req, State} when Req::cowboy_req:req(), State::any(). -optional_callbacks([last_modified/2]). @@ -1531,6 +1531,11 @@ last_modified(Req, State=#state{last_modified=undefined}) -> case unsafe_call(Req, State, last_modified) of no_call -> {undefined, Req, State#state{last_modified=no_call}}; + %% We allow the callback to return 'undefined', + %% in which case the generated header would be missing + %% as if the callback was not called. + {undefined, Req2, State2} -> + {undefined, Req2, State2#state{last_modified=no_call}}; {LastModified, Req2, State2} -> {LastModified, Req2, State2#state{last_modified=LastModified}} end; |