diff options
author | José Valim <jose.valim@gmail.com> | 2011-05-10 16:53:57 +0200 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2011-05-10 16:53:57 +0200 |
commit | 3aa8f348efd1e7b504c342a2b53a21d6a5eae32e (patch) | |
tree | e63879412f79a23c8e453453824ff870cbb3c463 /actionpack/lib/action_dispatch/http/cache.rb | |
parent | 4d5ce4738b6f8c1d1abcd128349d3eaac1fffcde (diff) | |
download | rails-3aa8f348efd1e7b504c342a2b53a21d6a5eae32e.tar.gz rails-3aa8f348efd1e7b504c342a2b53a21d6a5eae32e.tar.bz2 rails-3aa8f348efd1e7b504c342a2b53a21d6a5eae32e.zip |
Fix previous commit by allowing a proc to be given as response_body. This is deprecated and is going to be removed in future releases.
Diffstat (limited to 'actionpack/lib/action_dispatch/http/cache.rb')
-rw-r--r-- | actionpack/lib/action_dispatch/http/cache.rb | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/actionpack/lib/action_dispatch/http/cache.rb b/actionpack/lib/action_dispatch/http/cache.rb index 4f4cb96a74..aaed0d750f 100644 --- a/actionpack/lib/action_dispatch/http/cache.rb +++ b/actionpack/lib/action_dispatch/http/cache.rb @@ -42,20 +42,6 @@ module ActionDispatch attr_reader :cache_control, :etag alias :etag? :etag - def initialize(*) - super - - @cache_control = {} - @etag = self["ETag"] - - if cache_control = self["Cache-Control"] - cache_control.split(/,\s*/).each do |segment| - first, last = segment.split("=") - @cache_control[first.to_sym] = last || true - end - end - end - def last_modified if last = headers['Last-Modified'] Time.httpdate(last) @@ -77,6 +63,18 @@ module ActionDispatch private + def prepare_cache_control! + @cache_control = {} + @etag = self["ETag"] + + if cache_control = self["Cache-Control"] + cache_control.split(/,\s*/).each do |segment| + first, last = segment.split("=") + @cache_control[first.to_sym] = last || true + end + end + end + def handle_conditional_get! if etag? || last_modified? || !@cache_control.empty? set_conditional_cache_control! |