File tree Expand file tree Collapse file tree 2 files changed +21
-3
lines changed Expand file tree Collapse file tree 2 files changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -44,9 +44,9 @@ def etag_matches?(etag)
44
44
# Reference: http://tools.ietf.org/html/rfc7232#section-6
45
45
def fresh? ( response )
46
46
if Request . strict_freshness
47
- if if_modified_since
47
+ if if_none_match
48
48
etag_matches? ( response . etag )
49
- elsif if_none_match
49
+ elsif if_modified_since
50
50
not_modified? ( response . last_modified )
51
51
else
52
52
false
Original file line number Diff line number Diff line change @@ -70,7 +70,25 @@ def test_etag_matches
70
70
assert_response :not_modified
71
71
end
72
72
73
- def test_etag_precedence_over_last_modified
73
+ def test_strict_freshness_with_etag
74
+ with_strict_freshness ( true ) do
75
+ @request . if_none_match = weak_etag ( [ :foo , 123 ] )
76
+
77
+ get :one
78
+ assert_response :not_modified
79
+ end
80
+ end
81
+
82
+ def test_strict_freshness_with_last_modified
83
+ with_strict_freshness ( true ) do
84
+ @request . if_modified_since = @last_modified
85
+
86
+ get :one
87
+ assert_response :not_modified
88
+ end
89
+ end
90
+
91
+ def test_strict_freshness_etag_precedence_over_last_modified
74
92
with_strict_freshness ( true ) do
75
93
# Not modified because the etag matches
76
94
@request . if_modified_since = 5 . years . ago . httpdate
You can’t perform that action at this time.
0 commit comments