diff options
author | Christopher Adams <[email protected]> | 2016-10-06 16:48:34 +0800 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2016-10-18 10:43:47 +0200 |
commit | 59c32506c076c5f99e8b404bfed69a1239372a07 (patch) | |
tree | a279c634253569250a08844857a7b1ecc10edbb4 | |
parent | 932f1301c557ae486839e4af085ab7c401c1a4f1 (diff) | |
download | cowboy-59c32506c076c5f99e8b404bfed69a1239372a07.tar.gz cowboy-59c32506c076c5f99e8b404bfed69a1239372a07.tar.bz2 cowboy-59c32506c076c5f99e8b404bfed69a1239372a07.zip |
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.
-rw-r--r-- | src/cowboy_rest.erl | 2 | ||||
-rw-r--r-- | test/http_SUITE.erl | 7 |
2 files changed, 8 insertions, 1 deletions
diff --git a/src/cowboy_rest.erl b/src/cowboy_rest.erl index b760df2..33ef1d7 100644 --- a/src/cowboy_rest.erl +++ b/src/cowboy_rest.erl @@ -782,7 +782,7 @@ if_modified_since_now(Req, State, IfModifiedSince) -> if_modified_since(Req, State, IfModifiedSince) -> try last_modified(Req, State) of - {no_call, Req2, State2} -> + {undefined, Req2, State2} -> method(Req2, State2); {LastModified, Req2, State2} -> case LastModified > IfModifiedSince of diff --git a/test/http_SUITE.erl b/test/http_SUITE.erl index f0670a9..7f12967 100644 --- a/test/http_SUITE.erl +++ b/test/http_SUITE.erl @@ -647,6 +647,13 @@ rest_expires_binary(Config) -> {_, <<"0">>} = lists:keyfind(<<"expires">>, 1, Headers), 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) -> ConnPid = gun_open(Config), Refs = [gun:get(ConnPid, "/simple") || _ <- lists:seq(1, 10)], |