diff options
author | José Valim <jose.valim@gmail.com> | 2010-09-22 21:40:14 +0200 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-10-03 21:25:22 +0200 |
commit | 74dd8a3681c6984ea35c879f88c6a87521b58ec2 (patch) | |
tree | 4952e210123b31c4149cf1747a00c619be5d3fa5 /actionpack/lib/action_dispatch | |
parent | 50215f9525b6b5e3bfe703724b9f68177ed8565d (diff) | |
download | rails-74dd8a3681c6984ea35c879f88c6a87521b58ec2.tar.gz rails-74dd8a3681c6984ea35c879f88c6a87521b58ec2.tar.bz2 rails-74dd8a3681c6984ea35c879f88c6a87521b58ec2.zip |
Move ETag and ConditionalGet logic from AD::Response to the middleware stack.
Diffstat (limited to 'actionpack/lib/action_dispatch')
-rw-r--r-- | actionpack/lib/action_dispatch/http/cache.rb | 22 | ||||
-rw-r--r-- | actionpack/lib/action_dispatch/http/response.rb | 2 |
2 files changed, 2 insertions, 22 deletions
diff --git a/actionpack/lib/action_dispatch/http/cache.rb b/actionpack/lib/action_dispatch/http/cache.rb index 047fab006e..4061222d11 100644 --- a/actionpack/lib/action_dispatch/http/cache.rb +++ b/actionpack/lib/action_dispatch/http/cache.rb @@ -50,8 +50,7 @@ module ActionDispatch if cache_control = self["Cache-Control"] cache_control.split(/,\s*/).each do |segment| first, last = segment.split("=") - last ||= true - @cache_control[first.to_sym] = last + @cache_control[first.to_sym] = last || true end end end @@ -88,28 +87,9 @@ module ActionDispatch def handle_conditional_get! if etag? || last_modified? || !@cache_control.empty? set_conditional_cache_control! - elsif nonempty_ok_response? - self.etag = body - - if request && request.etag_matches?(etag) - self.status = 304 - self.body = [] - end - - set_conditional_cache_control! - else - headers["Cache-Control"] = "no-cache" end end - def nonempty_ok_response? - @status == 200 && string_body? - end - - def string_body? - !@blank && @body.respond_to?(:all?) && @body.all? { |part| part.is_a?(String) } - end - DEFAULT_CACHE_CONTROL = "max-age=0, private, must-revalidate" def set_conditional_cache_control! diff --git a/actionpack/lib/action_dispatch/http/response.rb b/actionpack/lib/action_dispatch/http/response.rb index 151c90167b..72871e328a 100644 --- a/actionpack/lib/action_dispatch/http/response.rb +++ b/actionpack/lib/action_dispatch/http/response.rb @@ -132,7 +132,7 @@ module ActionDispatch # :nodoc: # information. attr_accessor :charset, :content_type - CONTENT_TYPE = "Content-Type" + CONTENT_TYPE = "Content-Type" cattr_accessor(:default_charset) { "utf-8" } |