mirror of https://github.com/rails/rails
use methods for accessing the cache control headers
Use the methods rack provides so we don't have to worry about the exact header key.
This commit is contained in:
parent
cddb700cc2
commit
895c359182
|
@ -29,7 +29,7 @@ GIT
|
|||
|
||||
GIT
|
||||
remote: git://github.com/rack/rack.git
|
||||
revision: e2a8388d59bbad0cb867150185770ad76e80d31a
|
||||
revision: e836fad64ba3a79f8169ef44aa97b7004fca5e86
|
||||
branch: master
|
||||
specs:
|
||||
rack (2.0.0.alpha)
|
||||
|
|
|
@ -91,11 +91,10 @@ module ActionDispatch
|
|||
|
||||
DATE = 'Date'.freeze
|
||||
LAST_MODIFIED = "Last-Modified".freeze
|
||||
CACHE_CONTROL = "Cache-Control".freeze
|
||||
SPECIAL_KEYS = Set.new(%w[extras no-cache max-age public must-revalidate])
|
||||
|
||||
def cache_control_segments
|
||||
if cache_control = get_header(CACHE_CONTROL)
|
||||
if cache_control = _cache_control
|
||||
cache_control.delete(' ').split(',')
|
||||
else
|
||||
[]
|
||||
|
@ -149,11 +148,11 @@ module ActionDispatch
|
|||
control.merge! cache_control
|
||||
|
||||
if control.empty?
|
||||
set_header CACHE_CONTROL, DEFAULT_CACHE_CONTROL
|
||||
self._cache_control = DEFAULT_CACHE_CONTROL
|
||||
elsif control[:no_cache]
|
||||
set_header CACHE_CONTROL, NO_CACHE
|
||||
self._cache_control = NO_CACHE
|
||||
if control[:extras]
|
||||
set_header(CACHE_CONTROL, get_header(CACHE_CONTROL) + ", #{control[:extras].join(', ')}")
|
||||
self._cache_control = _cache_control + ", #{control[:extras].join(', ')}"
|
||||
end
|
||||
else
|
||||
extras = control[:extras]
|
||||
|
@ -165,7 +164,7 @@ module ActionDispatch
|
|||
options << MUST_REVALIDATE if control[:must_revalidate]
|
||||
options.concat(extras) if extras
|
||||
|
||||
set_header CACHE_CONTROL, options.join(", ")
|
||||
self._cache_control = options.join(", ")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -78,6 +78,10 @@ module ActionDispatch # :nodoc:
|
|||
cattr_accessor(:default_headers)
|
||||
|
||||
include Rack::Response::Helpers
|
||||
# Aliasing these off because AD::Http::Cache::Response defines them
|
||||
alias :_cache_control :cache_control
|
||||
alias :_cache_control= :cache_control=
|
||||
|
||||
include ActionDispatch::Http::FilterRedirect
|
||||
include ActionDispatch::Http::Cache::Response
|
||||
include MonitorMixin
|
||||
|
|
Loading…
Reference in New Issue