Check If-None-Match before If-Modified-Since with strict freshness
This commit is contained in:
parent
9f178ada79
commit
bdd9f4e89e
@ -44,9 +44,9 @@ def etag_matches?(etag)
|
||||
# Reference: http://tools.ietf.org/html/rfc7232#section-6
|
||||
def fresh?(response)
|
||||
if Request.strict_freshness
|
||||
if if_modified_since
|
||||
if if_none_match
|
||||
etag_matches?(response.etag)
|
||||
elsif if_none_match
|
||||
elsif if_modified_since
|
||||
not_modified?(response.last_modified)
|
||||
else
|
||||
false
|
||||
|
@ -70,7 +70,25 @@ def test_etag_matches
|
||||
assert_response :not_modified
|
||||
end
|
||||
|
||||
def test_etag_precedence_over_last_modified
|
||||
def test_strict_freshness_with_etag
|
||||
with_strict_freshness(true) do
|
||||
@request.if_none_match = weak_etag([:foo, 123])
|
||||
|
||||
get :one
|
||||
assert_response :not_modified
|
||||
end
|
||||
end
|
||||
|
||||
def test_strict_freshness_with_last_modified
|
||||
with_strict_freshness(true) do
|
||||
@request.if_modified_since = @last_modified
|
||||
|
||||
get :one
|
||||
assert_response :not_modified
|
||||
end
|
||||
end
|
||||
|
||||
def test_strict_freshness_etag_precedence_over_last_modified
|
||||
with_strict_freshness(true) do
|
||||
# Not modified because the etag matches
|
||||
@request.if_modified_since = 5.years.ago.httpdate
|
||||
|
Loading…
Reference in New Issue
Block a user