aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/http/request.rb
diff options
context:
space:
mode:
authorYehuda Katz <wycats@gmail.com>2009-10-26 17:32:42 -0700
committerYehuda Katz <wycats@gmail.com>2009-10-26 17:32:42 -0700
commite1786ee6ebee9fab10d6756be1eeacbbe6b65b48 (patch)
tree403392cf338502f200949f6c59dfcd4be30c1e79 /actionpack/lib/action_dispatch/http/request.rb
parentd7499f8ee8faa80d12dccae5baf5ab2acc79e77d (diff)
downloadrails-e1786ee6ebee9fab10d6756be1eeacbbe6b65b48.tar.gz
rails-e1786ee6ebee9fab10d6756be1eeacbbe6b65b48.tar.bz2
rails-e1786ee6ebee9fab10d6756be1eeacbbe6b65b48.zip
Fixes expires_now and cleans things up a bit
Diffstat (limited to 'actionpack/lib/action_dispatch/http/request.rb')
-rwxr-xr-xactionpack/lib/action_dispatch/http/request.rb21
1 files changed, 9 insertions, 12 deletions
diff --git a/actionpack/lib/action_dispatch/http/request.rb b/actionpack/lib/action_dispatch/http/request.rb
index bff030f0e4..1e366520c9 100755
--- a/actionpack/lib/action_dispatch/http/request.rb
+++ b/actionpack/lib/action_dispatch/http/request.rb
@@ -136,19 +136,16 @@ module ActionDispatch
# 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)
- 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
+ last_modified = if_modified_since
+ etag = if_none_match
- ONLY_ALL = [Mime::ALL].freeze
+ return false unless last_modified || etag
+
+ success = true
+ success &&= not_modified?(response.last_modified) if last_modified
+ success &&= etag_matches?(response.etag) if etag
+ success
+ end
# Returns the Mime type for the \format used in the request.
#