Merge pull request #34885 from y-yagi/fixes_34780

Allow using combine the Cache-Control `public` and `no-cache` headers
This commit is contained in:
Yuji Yaginuma 2019-01-09 07:59:16 +09:00 committed by GitHub
commit b03d493cf6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 4 deletions

@ -197,10 +197,12 @@ def merge_and_normalize_cache_control!(cache_control)
if control.empty?
# Let middleware handle default behavior
elsif control[:no_cache]
self._cache_control = NO_CACHE
if control[:extras]
self._cache_control = _cache_control + ", #{control[:extras].join(', ')}"
end
options = []
options << PUBLIC if control[:public]
options << NO_CACHE
options.concat(control[:extras]) if control[:extras]
self._cache_control = options.join(", ")
else
extras = control[:extras]
max_age = control[:max_age]

@ -183,6 +183,11 @@ def conditional_hello_without_expires_and_confliciting_cache_control_headers
render action: "hello_world"
end
def conditional_hello_without_expires_and_public_header
response.headers["Cache-Control"] = "public, no-cache"
render action: "hello_world"
end
def conditional_hello_with_bangs
render action: "hello_world"
end
@ -418,6 +423,11 @@ def test_no_expires_now_with_conflicting_cache_control_headers
assert_equal "no-cache", @response.headers["Cache-Control"]
end
def test_no_expires_now_with_public
get :conditional_hello_without_expires_and_public_header
assert_equal "public, no-cache", @response.headers["Cache-Control"]
end
def test_date_header_when_expires_in
time = Time.mktime(2011, 10, 30)
Time.stub :now, time do