diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2008-10-21 02:30:13 +0200 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2008-10-21 02:30:13 +0200 |
commit | 9acb88e666269204821b78bec7b72d3d16597096 (patch) | |
tree | 7ccdbde942b6cd97fe2c522dd6c9ccb60279393b /actionpack/lib/action_controller/request.rb | |
parent | c79f1d281f1932d4203c7b5b5c793e370ed63838 (diff) | |
download | rails-9acb88e666269204821b78bec7b72d3d16597096.tar.gz rails-9acb88e666269204821b78bec7b72d3d16597096.tar.bz2 rails-9acb88e666269204821b78bec7b72d3d16597096.zip |
Added stale?/fresh? and fresh_when methods to provide a layer of abstraction above request.fresh? and friends [DHH]
Diffstat (limited to 'actionpack/lib/action_controller/request.rb')
-rwxr-xr-x | actionpack/lib/action_controller/request.rb | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/actionpack/lib/action_controller/request.rb b/actionpack/lib/action_controller/request.rb index 5e492e3ee1..9f33cbc55f 100755 --- a/actionpack/lib/action_controller/request.rb +++ b/actionpack/lib/action_controller/request.rb @@ -120,9 +120,19 @@ module ActionController end # Check response freshness (Last-Modified and ETag) against request - # If-Modified-Since and If-None-Match conditions. + # If-Modified-Since and If-None-Match conditions. If both headers are + # supplied, both must match, or the request is not considered fresh. def fresh?(response) - not_modified?(response.last_modified) || etag_matches?(response.etag) + case + when if_modified_since && if_none_match + not_modified?(response.last_modified) && etag_matches?(response.etag) + when if_modified_since + not_modified?(response.last_modified) + when if_none_match + etag_matches?(response.etag) + else + false + end end # Returns the Mime type for the \format used in the request. |