0
Fork 0
mirror of https://github.com/ninenines/cowboy.git synced 2025-07-14 20:30:23 +00:00

Fix if_modified_since match of last_modified

Correct expected return type from `no_call` to `undefined` in
if_modified_since when last_modified callback is not defined. Add an
http_SUITE test to catch regressions.
This commit is contained in:
Christopher Adams 2016-10-06 16:48:34 +08:00 committed by Loïc Hoguin
parent 932f1301c5
commit 59c32506c0
No known key found for this signature in database
GPG key ID: 71366FF21851DF03
2 changed files with 8 additions and 1 deletions

View file

@ -782,7 +782,7 @@ if_modified_since_now(Req, State, IfModifiedSince) ->
if_modified_since(Req, State, IfModifiedSince) -> if_modified_since(Req, State, IfModifiedSince) ->
try last_modified(Req, State) of try last_modified(Req, State) of
{no_call, Req2, State2} -> {undefined, Req2, State2} ->
method(Req2, State2); method(Req2, State2);
{LastModified, Req2, State2} -> {LastModified, Req2, State2} ->
case LastModified > IfModifiedSince of case LastModified > IfModifiedSince of

View file

@ -647,6 +647,13 @@ rest_expires_binary(Config) ->
{_, <<"0">>} = lists:keyfind(<<"expires">>, 1, Headers), {_, <<"0">>} = lists:keyfind(<<"expires">>, 1, Headers),
ok. ok.
rest_last_modified_undefined(Config) ->
ConnPid = gun_open(Config),
Ref = gun:get(ConnPid, "/simple",
[{<<"if-modified-since">>, <<"Fri, 21 Sep 2012 22:36:14 GMT">>}]),
{response, nofin, 200, _} = gun:await(ConnPid, Ref),
ok.
rest_keepalive(Config) -> rest_keepalive(Config) ->
ConnPid = gun_open(Config), ConnPid = gun_open(Config),
Refs = [gun:get(ConnPid, "/simple") || _ <- lists:seq(1, 10)], Refs = [gun:get(ConnPid, "/simple") || _ <- lists:seq(1, 10)],