aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/http
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2009-11-02 23:46:00 -0200
committerJosé Valim <jose.valim@gmail.com>2009-11-02 23:46:00 -0200
commitd002826e54415a340e55fdbf363d005faebf8fc5 (patch)
tree431146dfb0b15c4507fd49bb7d6f18bd40ccf839 /actionpack/lib/action_dispatch/http
parent9ba83cce0318fa5051764f4a16c286adf30169e2 (diff)
parent14370e1aab6ddfb5b86cf50bd7e5abcebae0684c (diff)
downloadrails-d002826e54415a340e55fdbf363d005faebf8fc5.tar.gz
rails-d002826e54415a340e55fdbf363d005faebf8fc5.tar.bz2
rails-d002826e54415a340e55fdbf363d005faebf8fc5.zip
Merge branch 'master' of git://github.com/rails/rails
Diffstat (limited to 'actionpack/lib/action_dispatch/http')
-rw-r--r--actionpack/lib/action_dispatch/http/mime_type.rb1
-rwxr-xr-xactionpack/lib/action_dispatch/http/request.rb29
-rw-r--r--actionpack/lib/action_dispatch/http/response.rb2
3 files changed, 16 insertions, 16 deletions
diff --git a/actionpack/lib/action_dispatch/http/mime_type.rb b/actionpack/lib/action_dispatch/http/mime_type.rb
index e85823d8db..c30897b32a 100644
--- a/actionpack/lib/action_dispatch/http/mime_type.rb
+++ b/actionpack/lib/action_dispatch/http/mime_type.rb
@@ -24,6 +24,7 @@ module Mime
LOOKUP = Hash.new { |h, k| h[k] = Type.new(k) unless k.blank? }
def self.[](type)
+ return type if type.is_a?(Type)
Type.lookup_by_extension(type.to_s)
end
diff --git a/actionpack/lib/action_dispatch/http/request.rb b/actionpack/lib/action_dispatch/http/request.rb
index bff030f0e4..75be2cc260 100755
--- a/actionpack/lib/action_dispatch/http/request.rb
+++ b/actionpack/lib/action_dispatch/http/request.rb
@@ -97,6 +97,10 @@ module ActionDispatch
end
end
+ def forgery_whitelisted?
+ method == :get || xhr? || content_type.nil? || !content_type.verify_request?
+ end
+
def media_type
content_type.to_s
end
@@ -136,19 +140,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.
#
@@ -204,10 +205,6 @@ module ActionDispatch
end
end
- def cache_format
- parameters[:format]
- end
-
# Returns true if the request's "X-Requested-With" header contains
# "XMLHttpRequest". (The Prototype Javascript library sends this header with
# every Ajax request.)
diff --git a/actionpack/lib/action_dispatch/http/response.rb b/actionpack/lib/action_dispatch/http/response.rb
index 3e3b473178..b3ed7c9d1a 100644
--- a/actionpack/lib/action_dispatch/http/response.rb
+++ b/actionpack/lib/action_dispatch/http/response.rb
@@ -270,6 +270,8 @@ module ActionDispatch # :nodoc:
if control.empty?
headers["Cache-Control"] = DEFAULT_CACHE_CONTROL
+ elsif @cache_control[:no_cache]
+ headers["Cache-Control"] = "no-cache"
else
extras = control[:extras]
max_age = control[:max_age]