0
Fork 0
mirror of https://github.com/ninenines/cowboy.git synced 2025-07-15 12:40:25 +00:00

REST: Ignore If...Since if If...Match header exists

The If-Modified-Since and If-Unmodified-Since headers are
only used when If-None-Match or If-Match were not found,
respectively. The latter are preferred by the standard
and the former is only there for compatibility with older
clients.
This commit is contained in:
Loïc Hoguin 2016-06-06 17:33:46 +02:00
parent 6d63557235
commit 493794145e

View file

@ -688,7 +688,7 @@ if_match(Req, State, EtagsList) ->
precondition_failed(Req2, State2); precondition_failed(Req2, State2);
{Etag, Req2, State2} -> {Etag, Req2, State2} ->
case lists:member(Etag, EtagsList) of case lists:member(Etag, EtagsList) of
true -> if_unmodified_since_exists(Req2, State2); true -> if_none_match_exists(Req2, State2);
%% Etag may be `undefined' which cannot be a member. %% Etag may be `undefined' which cannot be a member.
false -> precondition_failed(Req2, State2) false -> precondition_failed(Req2, State2)
end end
@ -743,7 +743,7 @@ if_none_match(Req, State, EtagsList) ->
Etag -> Etag ->
case is_weak_match(Etag, EtagsList) of case is_weak_match(Etag, EtagsList) of
true -> precondition_is_head_get(Req2, State2); true -> precondition_is_head_get(Req2, State2);
false -> if_modified_since_exists(Req2, State2) false -> method(Req2, State2)
end end
end end
catch Class:Reason -> catch Class:Reason ->