Bug 1474250 [wpt PR 11850] - Revise HTTP caching tests, a=testonly

Automatic update from web-platform-testsMerge pull request #11850 from mnot/revise-caching

Revise HTTP caching tests
--

wpt-commits: aeea26ba803dcdcaf6d371b598a86e04a7dd93fa
wpt-pr: 11850
This commit is contained in:
Mark Nottingham 2018-07-18 14:30:43 +00:00 коммит произвёл moz-wptsync-bot
Родитель f9f82fa0eb
Коммит 1281faf21f
12 изменённых файлов: 576 добавлений и 488 удалений

Просмотреть файл

@ -340999,7 +340999,9 @@
"fetch/http-cache/304-update.html": [
[
"/fetch/http-cache/304-update.html",
{}
{
"timeout": "long"
}
]
],
"fetch/http-cache/cc-request.html": [
@ -341029,7 +341031,9 @@
"fetch/http-cache/invalidate.html": [
[
"/fetch/http-cache/invalidate.html",
{}
{
"timeout": "long"
}
]
],
"fetch/http-cache/partial.html": [
@ -573058,11 +573062,11 @@
"support"
],
"fetch/http-cache/304-update.html": [
"2571df43eb57ecbd29f55c2fc57b16f227001787",
"3f8fa7c0d25d6f3d1ec12ddd4e28e9c922115ed6",
"testharness"
],
"fetch/http-cache/README.md": [
"b9ccc7958ae3b00cd1b9c08b1e673b49ace0ca1c",
"5d07e2fc10b7898469cd73dd0a3c91dc4d09ee88",
"support"
],
"fetch/http-cache/basic-auth-cache-test-ref.html": [
@ -573074,31 +573078,31 @@
"reftest"
],
"fetch/http-cache/cc-request.html": [
"2002d341679139428e164cfe916dd39b9b664a3e",
"e6b5bb75f0b4997bbbaff068ddfc4d7a99d86455",
"testharness"
],
"fetch/http-cache/freshness.html": [
"84016c3d56e01f8f6be52cf4d26a0e4e860b9147",
"a2e67ceb2e2a70ec9a05a7721435a45490438c1d",
"testharness"
],
"fetch/http-cache/heuristic.html": [
"63837026eb6085fc7d6220c3dcab200b4bcd1eca",
"923e1608cb2880a5f03bd0b915aac035454a2778",
"testharness"
],
"fetch/http-cache/http-cache.js": [
"a61ea6705ce517f1e8e0e522026a75f1dbbe5a0e",
"f1142531189d038d8eb0bf66e1f9c3b7784a780b",
"support"
],
"fetch/http-cache/invalidate.html": [
"848a26000ed9bf4c61516201e4006b97839bee11",
"ca588057fbc10f1f9aef56c2c8284e36ac01ee4c",
"testharness"
],
"fetch/http-cache/partial.html": [
"685057fe8876321a5d42bcf1e7582e6f0b745f85",
"8030a72a24325cd4b872164328829a6dad4a5f0c",
"testharness"
],
"fetch/http-cache/resources/http-cache.py": [
"00b65e27915c5d16f0de04821eacc675b32e4ee7",
"7d1e5b92d4b2229051c24f5c927a22843f549705",
"support"
],
"fetch/http-cache/resources/securedimage.py": [
@ -573106,11 +573110,11 @@
"support"
],
"fetch/http-cache/status.html": [
"dac72c83edb75519e8ef5c3324442def4f380349",
"c98cdde7d574189daed43241e2de8aaf118712bc",
"testharness"
],
"fetch/http-cache/vary.html": [
"45f337270cfa90932c7469802655e313367ac92f",
"01571c540abef4a2cbc963c7c645739411179c02",
"testharness"
],
"fetch/nosniff/image.html": [

Просмотреть файл

@ -4,6 +4,7 @@
<meta charset="utf-8">
<title>HTTP Cache - 304 Updates</title>
<meta name="help" href="https://fetch.spec.whatwg.org/#request">
<meta name="timeout" content="long">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/utils.js"></script>
@ -14,19 +15,19 @@
<script>
var tests = [
{
name: 'HTTP cache updates returned headers from a Last-Modified 304.',
name: "HTTP cache updates returned headers from a Last-Modified 304",
requests: [
{
response_headers: [
["Expires", http_date(-5000)],
["Last-Modified", http_date(-3000)],
["Expires", -5000],
["Last-Modified", -3000],
["Test-Header", "A"]
]
},
{
response_headers: [
["Expires", http_date(-3000)],
["Last-Modified", http_date(-3000)],
["Expires", -3000],
["Last-Modified", -3000],
["Test-Header", "B"]
],
expected_type: "lm_validated",
@ -37,25 +38,26 @@
]
},
{
name: 'HTTP cache updates stored headers from a Last-Modified 304.',
name: "HTTP cache updates stored headers from a Last-Modified 304",
requests: [
{
response_headers: [
["Expires", http_date(-5000)],
["Last-Modified", http_date(-3000)],
["Expires", -5000],
["Last-Modified", -3000],
["Test-Header", "A"]
]
},
{
response_headers: [
["Expires", http_date(3000)],
["Last-Modified", http_date(-3000)],
["Expires", 3000],
["Last-Modified", -3000],
["Test-Header", "B"]
],
expected_type: "lm_validated",
expected_response_headers: [
["Test-Header", "B"]
]
],
pause_after: true
},
{
expected_type: "cached",
@ -66,18 +68,18 @@
]
},
{
name: 'HTTP cache updates returned headers from a ETag 304.',
name: "HTTP cache updates returned headers from a ETag 304",
requests: [
{
response_headers: [
["Expires", http_date(-5000)],
["Expires", -5000],
["ETag", "ABC"],
["Test-Header", "A"]
]
},
{
response_headers: [
["Expires", http_date(-3000)],
["Expires", -3000],
["ETag", "ABC"],
["Test-Header", "B"]
],
@ -89,25 +91,26 @@
]
},
{
name: 'HTTP cache updates stored headers from a ETag 304.',
name: "HTTP cache updates stored headers from a ETag 304",
requests: [
{
response_headers: [
["Expires", http_date(-5000)],
["Expires", -5000],
["ETag", "DEF"],
["Test-Header", "A"]
]
},
{
response_headers: [
["Expires", http_date(3000)],
["Expires", 3000],
["ETag", "DEF"],
["Test-Header", "B"]
],
expected_type: "etag_validated",
expected_response_headers: [
["Test-Header", "B"]
]
],
pause_after: true
},
{
expected_type: "cached",

Просмотреть файл

@ -22,3 +22,50 @@ A few notes:
* At the moment, Edge doesn't appear to using HTTP caching in conjunction
with Fetch at all.
## Test Format
Each test run gets its own URL and randomized content and operates independently.
Each test is an an array of objects, with the following members:
- `name` - The name of the test.
- `requests` - a list of request objects (see below).
Possible members of a request object:
- template - A template object for the request, by name.
- request_method - A string containing the HTTP method to be used.
- request_headers - An array of `[header_name_string, header_value_string]` arrays to
emit in the request.
- request_body - A string to use as the request body.
- mode - The mode string to pass to `fetch()`.
- credentials - The credentials string to pass to `fetch()`.
- cache - The cache string to pass to `fetch()`.
- pause_after - Boolean controlling a 3-second pause after the request completes.
- response_status - A `[number, string]` array containing the HTTP status code
and phrase to return.
- response_headers - An array of `[header_name_string, header_value_string]` arrays to
emit in the response. These values will also be checked like
expected_response_headers, unless there is a third value that is
`false`. See below for special handling considerations.
- response_body - String to send as the response body. If not set, it will contain
the test identifier.
- expected_type - One of `["cached", "not_cached", "lm_validate", "etag_validate", "error"]`
- expected_status - A number representing a HTTP status code to check the response for.
If not set, the value of `response_status[0]` will be used; if that
is not set, 200 will be used.
- expected_request_headers - An array of `[header_name_string, header_value_string]` representing
headers to check the request for.
- expected_response_headers - An array of `[header_name_string, header_value_string]` representing
headers to check the response for. See also response_headers.
- expected_response_text - A string to check the response body against. If not present, `response_body` will be checked if present and non-null; otherwise the response body will be checked for the test uuid (unless the status code disallows a body). Set to `null` to disable all response body checking.
Some headers in `response_headers` are treated specially:
* For date-carrying headers, if the value is a number, it will be interpreted as a delta to the time of the first request at the server.
* For URL-carrying headers, the value will be appended as a query parameter for `target`.
See the source for exact details.

Просмотреть файл

@ -15,7 +15,7 @@
<script>
var tests = [
{
name: "HTTP cache doesn't use aged but fresh response when request contains Cache-Control: max-age=0.",
name: "HTTP cache doesn't use aged but fresh response when request contains Cache-Control: max-age=0",
requests: [
{
template: "fresh",
@ -25,12 +25,12 @@
request_headers: [
["Cache-Control", "max-age=0"]
],
expected_type: "not_cached",
expected_type: "not_cached"
}
]
},
{
name: "HTTP cache doesn't use aged but fresh response when request contains Cache-Control: max-age=1.",
name: "HTTP cache doesn't use aged but fresh response when request contains Cache-Control: max-age=1",
requests: [
{
template: "fresh",
@ -40,12 +40,12 @@
request_headers: [
["Cache-Control", "max-age=1"]
],
expected_type: "not_cached",
expected_type: "not_cached"
}
]
},
{
name: "HTTP cache doesn't use fresh response with Age header when request contains Cache-Control: max-age that is greater than remaining freshness.",
name: "HTTP cache doesn't use fresh response with Age header when request contains Cache-Control: max-age that is greater than remaining freshness",
requests: [
{
response_headers: [
@ -57,12 +57,12 @@
request_headers: [
["Cache-Control", "max-age=600"]
],
expected_type: "not_cached",
expected_type: "not_cached"
}
]
},
{
name: "HTTP cache does use aged stale response when request contains Cache-Control: max-stale that permits its use.",
name: "HTTP cache does use aged stale response when request contains Cache-Control: max-stale that permits its use",
requests: [
{
response_headers: [
@ -74,12 +74,12 @@
request_headers: [
["Cache-Control", "max-stale=1000"]
],
expected_type: "cached",
expected_type: "cached"
}
]
},
{
name: "HTTP cache does reuse stale response with Age header when request contains Cache-Control: max-stale that permits its use.",
name: "HTTP cache does reuse stale response with Age header when request contains Cache-Control: max-stale that permits its use",
requests: [
{
response_headers: [
@ -91,12 +91,12 @@
request_headers: [
["Cache-Control", "max-stale=1000"]
],
expected_type: "cached",
expected_type: "cached"
}
]
},
{
name: "HTTP cache doesn't reuse fresh response when request contains Cache-Control: min-fresh that wants it fresher.",
name: "HTTP cache doesn't reuse fresh response when request contains Cache-Control: min-fresh that wants it fresher",
requests: [
{
response_headers: [
@ -107,12 +107,12 @@
request_headers: [
["Cache-Control", "min-fresh=2000"]
],
expected_type: "not_cached",
expected_type: "not_cached"
}
]
},
{
name: "HTTP cache doesn't reuse fresh response with Age header when request contains Cache-Control: min-fresh that wants it fresher.",
name: "HTTP cache doesn't reuse fresh response with Age header when request contains Cache-Control: min-fresh that wants it fresher",
requests: [
{
response_headers: [
@ -124,45 +124,45 @@
request_headers: [
["Cache-Control", "min-fresh=1000"]
],
expected_type: "not_cached",
expected_type: "not_cached"
}
]
},
{
name: "HTTP cache doesn't reuse fresh response when request contains Cache-Control: no-cache.",
name: "HTTP cache doesn't reuse fresh response when request contains Cache-Control: no-cache",
requests: [
{
response_headers: [
["Cache-Control", "max-age=3600"],
["Cache-Control", "max-age=3600"]
]
},
{
request_headers: [
["Cache-Control", "no-cache"]
],
expected_type: "not_cached",
expected_type: "not_cached"
}
]
},
{
name: "HTTP cache validates fresh response with Last-Modified when request contains Cache-Control: no-cache.",
name: "HTTP cache validates fresh response with Last-Modified when request contains Cache-Control: no-cache",
requests: [
{
response_headers: [
["Cache-Control", "max-age=3600"],
["Last-Modified", http_date(-10000)]
["Last-Modified", -10000]
]
},
{
request_headers: [
["Cache-Control", "no-cache"]
],
expected_type: "lm_validate",
expected_type: "lm_validate"
}
]
},
{
name: "HTTP cache validates fresh response with ETag when request contains Cache-Control: no-cache.",
name: "HTTP cache validates fresh response with ETag when request contains Cache-Control: no-cache",
requests: [
{
response_headers: [
@ -174,35 +174,35 @@
request_headers: [
["Cache-Control", "no-cache"]
],
expected_type: "etag_validate",
expected_type: "etag_validate"
}
]
},
{
name: "HTTP cache doesn't reuse fresh response when request contains Cache-Control: no-store.",
name: "HTTP cache doesn't reuse fresh response when request contains Cache-Control: no-store",
requests: [
{
response_headers: [
["Cache-Control", "max-age=3600"],
["Cache-Control", "max-age=3600"]
]
},
{
request_headers: [
["Cache-Control", "no-store"]
],
expected_type: "not_cached",
expected_type: "not_cached"
}
]
},
{
name: 'HTTP cache generates 504 status code when nothing is in cache and request contains Cache-Control: only-if-cached.',
name: "HTTP cache generates 504 status code when nothing is in cache and request contains Cache-Control: only-if-cached",
requests: [
{
request_headers: [
["Cache-Control", "only-if-cached"]
],
expected_status: 504,
expected_response_text: ""
expected_response_text: null
}
]
}

Просмотреть файл

@ -16,46 +16,46 @@
var tests = [
// response directives
{
name: 'HTTP cache reuses a response with a future Expires.',
name: "HTTP cache reuses a response with a future Expires",
requests: [
{
response_headers: [
["Expires", http_date(30*24*60*60)]
["Expires", (30 * 24 * 60 * 60)]
]
},
{
expected_type: "cached",
expected_type: "cached"
}
]
},
{
name: 'HTTP cache does not reuse a response with a past Expires.',
name: "HTTP cache does not reuse a response with a past Expires",
requests: [
{
response_headers: [
["Expires", http_date(-30*24*60*60)]
["Expires", (-30 * 24 * 60 * 60)]
]
},
{
expected_type: "not_cached",
expected_type: "not_cached"
}
]
},
{
name: 'HTTP cache does not reuse a response with a present Expires.',
name: "HTTP cache does not reuse a response with a present Expires",
requests: [
{
response_headers: [
["Expires", http_date(0)]
["Expires", 0]
]
},
{
expected_type: "not_cached",
expected_type: "not_cached"
}
]
},
{
name: 'HTTP cache does not reuse a response with an invalid Expires.',
name: "HTTP cache does not reuse a response with an invalid Expires",
requests: [
{
response_headers: [
@ -63,12 +63,12 @@
]
},
{
expected_type: "not_cached",
expected_type: "not_cached"
}
]
},
{
name: 'HTTP cache reuses a response with positive Cache-Control: max-age.',
name: "HTTP cache reuses a response with positive Cache-Control: max-age",
requests: [
{
response_headers: [
@ -76,12 +76,12 @@
]
},
{
expected_type: "cached",
expected_type: "cached"
}
]
},
{
name: 'HTTP cache does not reuse a response with Cache-Control: max-age=0.',
name: "HTTP cache does not reuse a response with Cache-Control: max-age=0",
requests: [
{
response_headers: [
@ -89,54 +89,54 @@
]
},
{
expected_type: "not_cached",
expected_type: "not_cached"
}
]
},
{
name: 'HTTP cache reuses a response with positive Cache-Control: max-age and a past Expires.',
name: "HTTP cache reuses a response with positive Cache-Control: max-age and a past Expires",
requests: [
{
response_headers: [
["Cache-Control", "max-age=3600"],
['Expires', http_date(-10000)]
["Expires", -10000]
]
},
{
expected_type: "cached",
expected_type: "cached"
}
]
},
{
name: 'HTTP cache reuses a response with positive Cache-Control: max-age and an invalid Expires.',
name: "HTTP cache reuses a response with positive Cache-Control: max-age and an invalid Expires",
requests: [
{
response_headers: [
["Cache-Control", "max-age=3600"],
['Expires', '0']
["Expires", "0"]
]
},
{
expected_type: "cached",
expected_type: "cached"
}
]
},
{
name: 'HTTP cache does not reuse a response with Cache-Control: max-age=0 and a future Expires.',
name: "HTTP cache does not reuse a response with Cache-Control: max-age=0 and a future Expires",
requests: [
{
response_headers: [
["Cache-Control", "max-age=0"],
['Expires', http_date(10000)]
["Expires", 10000]
]
},
{
expected_type: "not_cached",
expected_type: "not_cached"
}
]
},
{
name: 'HTTP cache does not prefer Cache-Control: s-maxage over Cache-Control: max-age.',
name: "HTTP cache does not prefer Cache-Control: s-maxage over Cache-Control: max-age",
requests: [
{
response_headers: [
@ -145,12 +145,12 @@
pause_after: true,
},
{
expected_type: "not_cached",
expected_type: "not_cached"
}
]
},
{
name: 'HTTP cache does not reuse a response when the Age header is greater than its freshness lifetime.',
name: "HTTP cache does not reuse a response when the Age header is greater than its freshness lifetime",
requests: [
{
response_headers: [
@ -159,12 +159,12 @@
],
},
{
expected_type: "not_cached",
expected_type: "not_cached"
}
]
},
{
name: 'HTTP cache does not store a response with Cache-Control: no-store.',
name: "HTTP cache does not store a response with Cache-Control: no-store",
requests: [
{
response_headers: [
@ -172,50 +172,50 @@
]
},
{
expected_type: "not_cached",
expected_type: "not_cached"
}
]
},
{
name: 'HTTP cache does not store a response with Cache-Control: no-store, even with max-age and Expires.',
name: "HTTP cache does not store a response with Cache-Control: no-store, even with max-age and Expires",
requests: [
{
response_headers: [
["Cache-Control", "max-age=10000, no-store"],
['Expires', http_date(10000)]
["Expires", 10000]
]
},
{
expected_type: "not_cached",
expected_type: "not_cached"
}
]
},
{
name: 'HTTP cache stores a response with Cache-Control: no-cache, but revalidates upon use.',
name: "HTTP cache stores a response with Cache-Control: no-cache, but revalidates upon use",
requests: [
{
response_headers: [
["Cache-Control", "no-cache"],
['ETag', 'abcd']
["ETag", "abcd"]
]
},
{
expected_type: "etag_validated",
expected_type: "etag_validated"
}
]
},
{
name: 'HTTP cache stores a response with Cache-Control: no-cache, but revalidates upon use, even with max-age and Expires.',
name: "HTTP cache stores a response with Cache-Control: no-cache, but revalidates upon use, even with max-age and Expires",
requests: [
{
response_headers: [
["Cache-Control", "max-age=10000, no-cache"],
['Expires', http_date(10000)],
['ETag', 'abcd']
["Expires", 10000],
["ETag", "abcd"]
]
},
{
expected_type: "etag_validated",
expected_type: "etag_validated"
}
]
},

Просмотреть файл

@ -15,32 +15,32 @@
<script>
var tests = [
{
name: 'HTTP cache reuses an unknown response with Last-Modified based upon heuristic freshness when Cache-Control: public is present.',
name: "HTTP cache reuses an unknown response with Last-Modified based upon heuristic freshness when Cache-Control: public is present",
requests: [
{
response_status: [299, "Whatever"],
response_headers: [
['Last-Modified', http_date(-3 * 100)],
['Cache-Control', 'public']
["Last-Modified", (-3 * 100)],
["Cache-Control", "public"]
],
},
{
expected_type: "cached",
response_status: [299, "Whatever"],
response_status: [299, "Whatever"]
}
]
},
{
name: 'HTTP cache does not reuse an unknown response with Last-Modified based upon heuristic freshness when Cache-Control: public is not present.',
name: "HTTP cache does not reuse an unknown response with Last-Modified based upon heuristic freshness when Cache-Control: public is not present",
requests: [
{
response_status: [299, "Whatever"],
response_headers: [
['Last-Modified', http_date(-3 * 100)]
["Last-Modified", (-3 * 100)]
],
},
{
expected_type: "not_cached",
expected_type: "not_cached"
}
]
}
@ -62,26 +62,26 @@
}
tests.push(
{
name: 'HTTP cache ' + desired + ' a ' + code + ' ' + phrase + ' response with Last-Modified based upon heuristic freshness.',
name: "HTTP cache " + desired + " a " + code + " " + phrase + " response with Last-Modified based upon heuristic freshness",
requests: [
{
response_status: [code, phrase],
response_headers: [
['Last-Modified', http_date(-3 * 100)]
["Last-Modified", (-3 * 100)]
],
response_body: body,
response_body: body
},
{
expected_type: expected_type,
response_status: [code, phrase],
response_body: body,
response_body: body
}
]
}
)
}
[
[true, 200, 'OK'],
[true, 200, "OK"],
[true, 203, "Non-Authoritative Information"],
[true, 204, "No Content", ""],
[true, 404, "Not Found"],
@ -91,7 +91,7 @@
[true, 501, "Not Implemented"]
].forEach(check_status);
[
[false, 201, 'Created'],
[false, 201, "Created"],
[false, 202, "Accepted"],
[false, 403, "Forbidden"],
[false, 502, "Bad Gateway"],

Просмотреть файл

@ -1,285 +1,259 @@
/**
* Each test run gets its own URL and randomized content and operates independently.
*
* Tests are an array of objects, each representing a request to make and check.
* The cache.py server script stashes an entry containing observed headers for
* each request it receives. When the test fetches have run, this state is retrieved
* and the expected_* lists are checked, including their length.
*
* Request object keys:
* - template - A template object for the request, by name -- see "templates" below.
* - request_method - A string containing the HTTP method to be used.
* - request_headers - An array of [header_name_string, header_value_string] arrays to
* emit in the request.
* - request_body - A string to use as the request body.
* - mode - The mode string to pass to fetch().
* - credentials - The credentials string to pass to fetch().
* - cache - The cache string to pass to fetch().
* - pause_after - Boolean controlling a 3-second pause after the request completes.
* - response_status - A [number, string] array containing the HTTP status code
* and phrase to return.
* - response_headers - An array of [header_name_string, header_value_string] arrays to
* emit in the response. These values will also be checked like
* expected_response_headers, unless there is a third value that is
* false.
* - response_body - String to send as the response body. If not set, it will contain
* the test identifier.
* - expected_type - One of ["cached", "not_cached", "lm_validate", "etag_validate", "error"]
* - expected_status - A number representing a HTTP status code to check the response for.
* If not set, the value of response_status[0] will be used; if that
* is not set, 200 will be used.
* - expected_request_headers - An array of [header_name_string, header_value_string] representing
* headers to check the request for.
* - expected_response_headers - An array of [header_name_string, header_value_string] representing
* headers to check the response for. See also response_headers.
* - expected_response_text - A string to check the response body against.
*/
/* global btoa fetch token promise_test step_timeout */
/* global assert_equals assert_true assert_own_property assert_throws assert_less_than */
function make_url(uuid, requests, idx) {
var arg = "";
if ("query_arg" in requests[idx]) {
arg = "&target=" + requests[idx].query_arg;
}
return "resources/http-cache.py?token=" + uuid + "&info=" + btoa(JSON.stringify(requests)) + arg;
}
function server_state(uuid) {
return fetch("resources/http-cache.py?querystate&token=" + uuid)
.then(function(response) {
return response.text();
}).then(function(text) {
// null will be returned if the server never received any requests
// for the given uuid. Normalize that to an empty list consistent
// with our representation.
return JSON.parse(text) || [];
});
}
templates = {
"fresh": {
"response_headers": [
['Expires', http_date(100000)],
['Last-Modified', http_date(0)]
const templates = {
'fresh': {
'response_headers': [
['Expires', 100000],
['Last-Modified', 0]
]
},
"stale": {
"response_headers": [
['Expires', http_date(-5000)],
['Last-Modified', http_date(-100000)]
'stale': {
'response_headers': [
['Expires', -5000],
['Last-Modified', -100000]
]
},
"lcl_response": {
"response_headers": [
['Location', "location_target"],
['Content-Location', "content_location_target"]
'lcl_response': {
'response_headers': [
['Location', 'location_target'],
['Content-Location', 'content_location_target']
]
},
"location": {
"query_arg": "location_target",
"response_headers": [
['Expires', http_date(100000)],
['Last-Modified', http_date(0)]
'location': {
'query_arg': 'location_target',
'response_headers': [
['Expires', 100000],
['Last-Modified', 0]
]
},
"content_location": {
"query_arg": "content_location_target",
"response_headers": [
['Expires', http_date(100000)],
['Last-Modified', http_date(0)]
'content_location': {
'query_arg': 'content_location_target',
'response_headers': [
['Expires', 100000],
['Last-Modified', 0]
]
}
}
function make_test(raw_requests) {
var requests = [];
for (var i = 0; i < raw_requests.length; i++) {
var request = raw_requests[i];
if ("template" in request) {
var template = templates[request["template"]];
for (var member in template) {
if (! request.hasOwnProperty(member)) {
request[member] = template[member];
}
}
}
if ("expected_type" in request && request.expected_type === "cached") {
// requests after one that's expected to be cached will get out of sync
// with the server; not currently supported.
if (raw_requests.length > i + 1) {
assert_unreached("Making requests after something is expected to be cached.");
}
}
requests.push(request);
}
return function(test) {
var uuid = token();
var fetch_functions = [];
for (var i = 0; i < requests.length; ++i) {
fetch_functions.push({
code: function(idx) {
var init = {};
var url = make_url(uuid, requests, idx);
var config = requests[idx];
if ("request_method" in config) {
init.method = config["request_method"];
}
if ("request_headers" in config) {
init.headers = config["request_headers"];
}
if ("request_body" in config) {
init.body = config["request_body"];
}
if ("mode" in config) {
init.mode = config["mode"];
}
if ("credentials" in config) {
init.mode = config["credentials"];
}
if ("cache" in config) {
init.cache = config["cache"];
}
const noBodyStatus = new Set([204, 304])
function makeTest (test) {
return function () {
var uuid = token()
var requests = expandTemplates(test)
var fetchFunctions = []
for (let i = 0; i < requests.length; ++i) {
fetchFunctions.push({
code: function (idx) {
var config = requests[idx]
var url = makeTestUrl(uuid, config)
var init = fetchInit(requests, config)
return fetch(url, init)
.then(function(response) {
var res_num = parseInt(response.headers.get("Server-Request-Count"));
var req_num = idx + 1;
if ("expected_type" in config) {
if (config.expected_type === "error") {
assert_true(false, "Request " + req_num + " should have been an error");
return [response.text(), response_status];
}
if (config.expected_type === "cached") {
assert_less_than(res_num, req_num, "Response used");
}
if (config.expected_type === "not_cached") {
assert_equals(res_num, req_num, "Response used");
}
}
if ("expected_status" in config) {
assert_equals(response.status, config.expected_status, "Response status");
} else if ("response_status" in config) {
assert_equals(response.status, config.response_status[0], "Response status");
.then(makeCheckResponse(idx, config))
.then(makeCheckResponseBody(config, uuid), function (reason) {
if ('expected_type' in config && config.expected_type === 'error') {
assert_throws(new TypeError(), function () { throw reason })
} else {
assert_equals(response.status, 200, "Response status")
throw reason
}
if ("response_headers" in config) {
config.response_headers.forEach(function(header) {
if (header.len < 3 || header[2] === true) {
assert_equals(response.headers.get(header[0]), header[1], "Response header")
}
})
}
if ("expected_response_headers" in config) {
config.expected_response_headers.forEach(function(header) {
assert_equals(response.headers.get(header[0]), header[1], "Response header");
});
}
return response.text();
}).then(function(res_body) {
if ("expected_response_text" in config) {
assert_equals(res_body, config.expected_response_text, "Response body");
} else if ("response_body" in config) {
assert_equals(res_body, config.response_body, "Response body");
} else {
assert_equals(res_body, uuid, "Response body");
}
}, function(reason) {
if ("expected_type" in config && config.expected_type === "error") {
assert_throws(new TypeError(), function() { throw reason; });
} else {
throw reason;
}
});
})
},
pause_after: "pause_after" in requests[i] && true || false
});
pauseAfter: 'pause_after' in requests[i]
})
}
function pause() {
return new Promise(function(resolve, reject) {
step_timeout(function() {
return resolve()
}, 3000);
});
}
// TODO: it would be nice if this weren't serialised.
var idx = 0;
function run_next_step() {
if (fetch_functions.length) {
var fetch_function = fetch_functions.shift();
if (fetch_function.pause_after > 0) {
return fetch_function.code(idx++)
var idx = 0
function runNextStep () {
if (fetchFunctions.length) {
var nextFetchFunction = fetchFunctions.shift()
if (nextFetchFunction.pauseAfter === true) {
return nextFetchFunction.code(idx++)
.then(pause)
.then(run_next_step);
.then(runNextStep)
} else {
return fetch_function.code(idx++)
.then(run_next_step);
return nextFetchFunction.code(idx++)
.then(runNextStep)
}
} else {
return Promise.resolve();
return Promise.resolve()
}
}
return run_next_step()
.then(function() {
// Now, query the server state
return server_state(uuid);
}).then(function(state) {
for (var i = 0; i < requests.length; ++i) {
var expected_validating_headers = []
var req_num = i + 1;
if ("expected_type" in requests[i]) {
if (requests[i].expected_type === "cached") {
assert_true(state.length <= i, "cached response used for request " + req_num);
continue; // the server will not see the request, so we can't check anything else.
}
if (requests[i].expected_type === "not_cached") {
assert_false(state.length <= i, "cached response used for request " + req_num);
}
if (requests[i].expected_type === "etag_validated") {
expected_validating_headers.push('if-none-match')
}
if (requests[i].expected_type === "lm_validated") {
expected_validating_headers.push('if-modified-since')
}
}
for (var j in expected_validating_headers) {
var vhdr = expected_validating_headers[j];
assert_own_property(state[i].request_headers, vhdr, " has " + vhdr + " request header");
}
if ("expected_request_headers" in requests[i]) {
var expected_request_headers = requests[i].expected_request_headers;
for (var j = 0; j < expected_request_headers.length; ++j) {
var expected_header = expected_request_headers[j];
assert_equals(state[i].request_headers[expected_header[0].toLowerCase()],
expected_header[1]);
}
}
}
});
};
}
function run_tests(tests)
{
tests.forEach(function(info) {
promise_test(make_test(info.requests), info.name);
});
}
function http_date(delta) {
return new Date(Date.now() + (delta * 1000)).toGMTString();
}
var content_store = {};
function http_content(cs_key) {
if (cs_key in content_store) {
return content_store[cs_key];
} else {
var content = btoa(Math.random() * Date.now());
content_store[cs_key] = content;
return content;
return runNextStep()
.then(function () {
return getServerState(uuid)
}).then(function (testState) {
checkRequests(requests, testState)
return Promise.resolve()
})
}
}
}
function expandTemplates (test) {
var rawRequests = test.requests
var requests = []
for (let i = 0; i < rawRequests.length; i++) {
var request = rawRequests[i]
request.name = test.name
if ('template' in request) {
var template = templates[request['template']]
for (let member in template) {
if (!request.hasOwnProperty(member)) {
request[member] = template[member]
}
}
}
requests.push(request)
}
return requests
}
function fetchInit (requests, config) {
var init = {
'headers': []
}
if ('request_method' in config) init.method = config['request_method']
if ('request_headers' in config) init.headers = config['request_headers']
if ('name' in config) init.headers.push(['Test-Name', config.name])
if ('request_body' in config) init.body = config['request_body']
if ('mode' in config) init.mode = config['mode']
if ('credentials' in config) init.mode = config['credentials']
if ('cache' in config) init.cache = config['cache']
init.headers.push(['Test-Requests', btoa(JSON.stringify(requests))])
return init
}
function makeCheckResponse (idx, config) {
return function checkResponse (response) {
var reqNum = idx + 1
var resNum = parseInt(response.headers.get('Server-Request-Count'))
if ('expected_type' in config) {
if (config.expected_type === 'error') {
assert_true(false, `Request ${reqNum} doesn't throw an error`)
return response.text()
}
if (config.expected_type === 'cached') {
assert_less_than(resNum, reqNum, `Response ${reqNum} does not come from cache`)
}
if (config.expected_type === 'not_cached') {
assert_equals(resNum, reqNum, `Response ${reqNum} comes from cache`)
}
}
if ('expected_status' in config) {
assert_equals(response.status, config.expected_status,
`Response ${reqNum} status is ${response.status}, not ${config.expected_status}`)
} else if ('response_status' in config) {
assert_equals(response.status, config.response_status[0],
`Response ${reqNum} status is ${response.status}, not ${config.response_status[0]}`)
} else {
assert_equals(response.status, 200, `Response ${reqNum} status is ${response.status}, not 200`)
}
if ('response_headers' in config) {
config.response_headers.forEach(function (header) {
if (header.len < 3 || header[2] === true) {
assert_equals(response.headers.get(header[0]), header[1],
`Response ${reqNum} header ${header[0]} is "${response.headers.get(header[0])}", not "${header[1]}"`)
}
})
}
if ('expected_response_headers' in config) {
config.expected_response_headers.forEach(function (header) {
assert_equals(response.headers.get(header[0]), header[1],
`Response ${reqNum} header ${header[0]} is "${response.headers.get(header[0])}", not "${header[1]}"`)
})
}
return response.text()
}
}
function makeCheckResponseBody (config, uuid) {
return function checkResponseBody (resBody) {
var statusCode = 200
if ('response_status' in config) {
statusCode = config.response_status[0]
}
if ('expected_response_text' in config) {
if (config.expected_response_text !== null) {
assert_equals(resBody, config.expected_response_text,
`Response body is "${resBody}", not expected "${config.expected_response_text}"`)
}
} else if ('response_body' in config && config.response_body !== null) {
assert_equals(resBody, config.response_body,
`Response body is "${resBody}", not sent "${config.response_body}"`)
} else if (!noBodyStatus.has(statusCode)) {
assert_equals(resBody, uuid, `Response body is "${resBody}", not default "${uuid}"`)
}
}
}
function checkRequests (requests, testState) {
var testIdx = 0
for (let i = 0; i < requests.length; ++i) {
var expectedValidatingHeaders = []
var config = requests[i]
var serverRequest = testState[testIdx]
var reqNum = i + 1
if ('expected_type' in config) {
if (config.expected_type === 'cached') continue // the server will not see the request
if (config.expected_type === 'etag_validated') {
expectedValidatingHeaders.push('if-none-match')
}
if (config.expected_type === 'lm_validated') {
expectedValidatingHeaders.push('if-modified-since')
}
}
testIdx++
expectedValidatingHeaders.forEach(vhdr => {
assert_own_property(serverRequest.request_headers, vhdr,
`request ${reqNum} doesn't have ${vhdr} header`)
})
if ('expected_request_headers' in config) {
config.expected_request_headers.forEach(expectedHdr => {
assert_equals(serverRequest.request_headers[expectedHdr[0].toLowerCase()], expectedHdr[1],
`request ${reqNum} header ${expectedHdr[0]} value is "${serverRequest.request_headers[expectedHdr[0].toLowerCase()]}", not "${expectedHdr[1]}"`)
})
}
}
}
function pause () {
return new Promise(function (resolve, reject) {
step_timeout(function () {
return resolve()
}, 3000)
})
}
function makeTestUrl (uuid, config) {
var arg = ''
if ('query_arg' in config) {
arg = `&target=${config.query_arg}`
}
return `resources/http-cache.py?dispatch=test&uuid=${uuid}${arg}`
}
function getServerState (uuid) {
return fetch(`resources/http-cache.py?dispatch=state&uuid=${uuid}`)
.then(function (response) {
return response.text()
}).then(function (text) {
return JSON.parse(text) || []
})
}
function run_tests (tests) {
tests.forEach(function (test) {
promise_test(makeTest(test), test.name)
})
}
var contentStore = {}
function http_content (csKey) {
if (csKey in contentStore) {
return contentStore[csKey]
} else {
var content = btoa(Math.random() * Date.now())
contentStore[csKey] = content
return content
}
}

Просмотреть файл

@ -4,6 +4,7 @@
<meta charset="utf-8">
<title>HTTP Cache - Invalidation</title>
<meta name="help" href="https://fetch.spec.whatwg.org/#request">
<meta name="timeout" content="long">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/utils.js"></script>
@ -20,7 +21,7 @@
template: "fresh"
}, {
request_method: "POST",
request_body: "abc",
request_body: "abc"
}, {
expected_type: "not_cached"
}
@ -48,7 +49,7 @@
}, {
template: "fresh",
request_method: "PUT",
request_body: "abc",
request_body: "abc"
}, {
expected_type: "not_cached"
}
@ -61,7 +62,7 @@
template: "fresh"
}, {
request_method: "DELETE",
request_body: "abc",
request_body: "abc"
}, {
expected_type: "not_cached"
}
@ -74,7 +75,7 @@
template: "fresh"
}, {
request_method: "FOO",
request_body: "abc",
request_body: "abc"
}, {
expected_type: "not_cached"
}
@ -121,7 +122,7 @@
}, {
template: "lcl_response",
request_method: "PUT",
request_body: "abc",
request_body: "abc"
}, {
template: "location",
expected_type: "not_cached"
@ -136,7 +137,7 @@
}, {
template: "lcl_response",
request_method: "DELETE",
request_body: "abc",
request_body: "abc"
}, {
template: "location",
expected_type: "not_cached"
@ -151,7 +152,7 @@
}, {
template: "lcl_response",
request_method: "FOO",
request_body: "abc",
request_body: "abc"
}, {
template: "location",
expected_type: "not_cached"
@ -200,7 +201,7 @@
}, {
template: "lcl_response",
request_method: "PUT",
request_body: "abc",
request_body: "abc"
}, {
template: "content_location",
expected_type: "not_cached"
@ -215,7 +216,7 @@
}, {
template: "lcl_response",
request_method: "DELETE",
request_body: "abc",
request_body: "abc"
}, {
template: "content_location",
expected_type: "not_cached"
@ -230,7 +231,7 @@
}, {
template: "lcl_response",
request_method: "FOO",
request_body: "abc",
request_body: "abc"
}, {
template: "content_location",
expected_type: "not_cached"

Просмотреть файл

@ -15,7 +15,7 @@
<script>
var tests = [
{
name: 'HTTP cache stores partial content and reuses it.',
name: "HTTP cache stores partial content and reuses it",
requests: [
{
request_headers: [
@ -23,17 +23,17 @@
],
response_status: [206, "Partial Content"],
response_headers: [
['Cache-Control', 'max-age=3600'],
['Content-Range', 'bytes 4-9/10']
["Cache-Control", "max-age=3600"],
["Content-Range", "bytes 4-9/10"]
],
response_body: "01234",
expected_request_headers: [
['Range', "bytes=-5"]
],
["Range", "bytes=-5"]
]
},
{
request_headers: [
['Range', "bytes=-5"]
["Range", "bytes=-5"]
],
expected_type: "cached",
expected_status: 206,
@ -42,13 +42,13 @@
]
},
{
name: 'HTTP cache stores complete response and serves smaller ranges from it(byte-range-spec).',
name: "HTTP cache stores complete response and serves smaller ranges from it (byte-range-spec)",
requests: [
{
response_headers: [
['Cache-Control', 'max-age=3600'],
["Cache-Control", "max-age=3600"]
],
response_body: "01234567890",
response_body: "01234567890"
},
{
request_headers: [
@ -61,13 +61,13 @@
]
},
{
name: 'HTTP cache stores complete response and serves smaller ranges from it(absent last-byte-pos).',
name: "HTTP cache stores complete response and serves smaller ranges from it (absent last-byte-pos)",
requests: [
{
response_headers: [
['Cache-Control', 'max-age=3600'],
["Cache-Control", "max-age=3600"],
],
response_body: "01234567890",
response_body: "01234567890"
},
{
request_headers: [
@ -80,13 +80,13 @@
]
},
{
name: 'HTTP cache stores complete response and serves smaller ranges from it(suffix-byte-range-spec).',
name: "HTTP cache stores complete response and serves smaller ranges from it (suffix-byte-range-spec)",
requests: [
{
response_headers: [
['Cache-Control', 'max-age=3600'],
["Cache-Control", "max-age=3600"],
],
response_body: "0123456789A",
response_body: "0123456789A"
},
{
request_headers: [
@ -99,7 +99,7 @@
]
},
{
name: 'HTTP cache stores partial response and serves smaller ranges from it(byte-range-spec).',
name: "HTTP cache stores partial response and serves smaller ranges from it (byte-range-spec)",
requests: [
{
request_headers: [
@ -107,10 +107,10 @@
],
response_status: [206, "Partial Content"],
response_headers: [
['Cache-Control', 'max-age=3600'],
['Content-Range', 'bytes 4-9/10']
["Cache-Control", "max-age=3600"],
["Content-Range", "bytes 4-9/10"]
],
response_body: "01234",
response_body: "01234"
},
{
request_headers: [
@ -123,7 +123,7 @@
]
},
{
name: 'HTTP cache stores partial response and serves smaller ranges from it(absent last-byte-pos).',
name: "HTTP cache stores partial response and serves smaller ranges from it (absent last-byte-pos)",
requests: [
{
request_headers: [
@ -131,14 +131,14 @@
],
response_status: [206, "Partial Content"],
response_headers: [
['Cache-Control', 'max-age=3600'],
['Content-Range', 'bytes 4-9/10']
["Cache-Control", "max-age=3600"],
["Content-Range", "bytes 4-9/10"]
],
response_body: "01234",
response_body: "01234"
},
{
request_headers: [
['Range', "bytes=6-"]
["Range", "bytes=6-"]
],
expected_type: "cached",
expected_status: 206,
@ -147,7 +147,7 @@
]
},
{
name: 'HTTP cache stores partial response and serves smaller ranges from it(suffix-byte-range-spec).',
name: "HTTP cache stores partial response and serves smaller ranges from it (suffix-byte-range-spec)",
requests: [
{
request_headers: [
@ -155,10 +155,10 @@
],
response_status: [206, "Partial Content"],
response_headers: [
['Cache-Control', 'max-age=3600'],
['Content-Range', 'bytes 4-9/10']
["Cache-Control", "max-age=3600"],
["Content-Range", "bytes 4-9/10"]
],
response_body: "01234",
response_body: "01234"
},
{
request_headers: [
@ -171,7 +171,7 @@
]
},
{
name: 'HTTP cache stores partial content and completes it.',
name: "HTTP cache stores partial content and completes it",
requests: [
{
request_headers: [
@ -179,10 +179,10 @@
],
response_status: [206, "Partial Content"],
response_headers: [
['Cache-Control', 'max-age=3600'],
['Content-Range', 'bytes 0-4/10']
["Cache-Control", "max-age=3600"],
["Content-Range", "bytes 0-4/10"]
],
response_body: "01234",
response_body: "01234"
},
{
expected_request_headers: [

Просмотреть файл

@ -1,34 +1,66 @@
from json import JSONEncoder, JSONDecoder
#!/usr/bin/env python
import datetime
import json
import time
from base64 import b64decode
NOTEHDRS = set(['content-type', 'access-control-allow-origin', 'last-modified', 'etag'])
NOBODYSTATUS = set([204, 304])
LOCATIONHDRS = set(['location', 'content-location'])
DATEHDRS = set(['date', 'expires', 'last-modified'])
def main(request, response):
uuid = request.GET.first("token", None)
if "querystate" in request.GET:
dispatch = request.GET.first("dispatch", None)
uuid = request.GET.first("uuid", None)
if not uuid:
response.status = (404, "Not Found")
response.headers.set("Content-Type", "text/plain")
return JSONEncoder().encode(request.server.stash.take(uuid))
return "UUID not found"
if dispatch == 'test':
return handle_test(uuid, request, response)
elif dispatch == 'state':
return handle_state(uuid, request, response)
response.status = (404, "Not Found")
response.headers.set("Content-Type", "text/plain")
return "Fallthrough"
server_state = request.server.stash.take(uuid)
if not server_state:
server_state = []
def handle_state(uuid, request, response):
response.headers.set("Content-Type", "text/plain")
return json.dumps(request.server.stash.take(uuid))
requests = JSONDecoder().decode(b64decode(request.GET.first("info", "")))
def handle_test(uuid, request, response):
server_state = request.server.stash.take(uuid) or []
try:
requests = json.loads(b64decode(request.headers.get('Test-Requests', "")))
except:
response.status = (400, "Bad Request")
response.headers.set("Content-Type", "text/plain")
return "No or bad Test-Requests request header"
config = requests[len(server_state)]
state = dict()
state["request_method"] = request.method
state["request_headers"] = dict([[h.lower(), request.headers[h]] for h in request.headers])
if not config:
response.status = (404, "Not Found")
response.headers.set("Content-Type", "text/plain")
return "Config not found"
noted_headers = {}
now = time.time()
for header in config.get('response_headers', []):
if header[0].lower() in LOCATIONHDRS: # magic locations
header[1] = "%s&target=%s" % (request.url, header[1])
if header[0].lower() in DATEHDRS and isinstance(header[1], int): # magic dates
header[1] = http_date(now, header[1])
response.headers.set(header[0], header[1])
if header[0].lower() in NOTEHDRS:
noted_headers[header[0].lower()] = header[1]
state = {
'now': now,
'request_method': request.method,
'request_headers': dict([[h.lower(), request.headers[h]] for h in request.headers]),
'response_headers': noted_headers
}
server_state.append(state)
request.server.stash.put(uuid, server_state)
note_headers = ['content-type', 'access-control-allow-origin', 'last-modified', 'etag']
noted_headers = {}
for header in config.get('response_headers', []):
if header[0].lower() in ["location", "content-location"]: # magic!
header[1] = "%s&target=%s" % (request.url, header[1])
response.headers.set(header[0], header[1])
if header[0].lower() in note_headers:
noted_headers[header[0].lower()] = header[1]
if "access-control-allow-origin" not in noted_headers:
response.headers.set("Access-Control-Allow-Origin", "*")
if "content-type" not in noted_headers:
@ -36,16 +68,42 @@ def main(request, response):
response.headers.set("Server-Request-Count", len(server_state))
code, phrase = config.get("response_status", [200, "OK"])
if request.headers.get("If-Modified-Since", False) == noted_headers.get('last-modified', True):
code, phrase = [304, "Not Modified"]
if request.headers.get("If-None-Match", False) == noted_headers.get('etag', True):
code, phrase = [304, "Not Modified"]
if config.get("expected_type", "").endswith('validated'):
ref_hdrs = server_state[0]['response_headers']
previous_lm = ref_hdrs.get('last-modified', False)
if previous_lm and request.headers.get("If-Modified-Since", False) == previous_lm:
code, phrase = [304, "Not Modified"]
previous_etag = ref_hdrs.get('etag', False)
if previous_etag and request.headers.get("If-None-Match", False) == previous_etag:
code, phrase = [304, "Not Modified"]
if code != 304:
code, phrase = [999, '304 Not Generated']
response.status = (code, phrase)
content = config.get("response_body", uuid)
if code in [204, 304]:
if code in NOBODYSTATUS:
return ""
else:
return content
return content
def get_header(headers, header_name):
result = None
for header in headers:
if header[0].lower() == header_name.lower():
result = header[1]
return result
WEEKDAYS = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
MONTHS = [None, 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul',
'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
def http_date(now, delta_secs=0):
date = datetime.datetime.utcfromtimestamp(now + delta_secs)
return "%s, %.2d %s %.4d %.2d:%.2d:%.2d GMT" % (
WEEKDAYS[date.weekday()],
date.day,
MONTHS[date.month],
date.year,
date.hour,
date.minute,
date.second)

Просмотреть файл

@ -21,7 +21,7 @@
body = http_content(code);
}
tests.push({
name: 'HTTP cache goes to the network if it has a stale ' + code + ' response.',
name: "HTTP cache goes to the network if it has a stale " + code + " response",
requests: [
{
template: "stale",
@ -29,12 +29,13 @@
response_body: body
}, {
expected_type: "not_cached",
response_status: [code, phrase],
response_body: body
}
]
})
tests.push({
name: 'HTTP cache avoids going to the network if it has a fresh ' + code + ' response.',
name: "HTTP cache avoids going to the network if it has a fresh " + code + " response",
requests: [
{
template: "fresh",
@ -49,9 +50,9 @@
})
}
[
[200, 'OK'],
[200, "OK"],
[203, "Non-Authoritative Information"],
[204, "No Content", ""],
[204, "No Content", null],
[299, "Whatever"],
[400, "Bad Request"],
[404, "Not Found"],

Просмотреть файл

@ -14,15 +14,15 @@
<script>
var tests = [
{
name: 'HTTP cache reuses Vary response when request matches.',
name: "HTTP cache reuses Vary response when request matches",
requests: [
{
request_headers: [
["Foo", "1"]
],
response_headers: [
["Expires", http_date(5000)],
["Last-Modified", http_date(-3000)],
["Expires", 5000],
["Last-Modified", -3000],
["Vary", "Foo"]
]
},
@ -35,15 +35,15 @@
]
},
{
name: "HTTP cache doesn't use Vary response when request doesn't match.",
name: "HTTP cache doesn't use Vary response when request doesn't match",
requests: [
{
request_headers: [
["Foo", "1"]
],
response_headers: [
["Expires", http_date(5000)],
["Last-Modified", http_date(-3000)],
["Expires", 5000],
["Last-Modified", -3000],
["Vary", "Foo"]
]
},
@ -56,15 +56,15 @@
]
},
{
name: "HTTP cache doesn't use Vary response when request omits variant header.",
name: "HTTP cache doesn't use Vary response when request omits variant header",
requests: [
{
request_headers: [
["Foo", "1"]
],
response_headers: [
["Expires", http_date(5000)],
["Last-Modified", http_date(-3000)],
["Expires", 5000],
["Last-Modified", -3000],
["Vary", "Foo"]
]
},
@ -74,15 +74,15 @@
]
},
{
name: "HTTP cache doesn't invalidate existing Vary response.",
name: "HTTP cache doesn't invalidate existing Vary response",
requests: [
{
request_headers: [
["Foo", "1"]
],
response_headers: [
["Expires", http_date(5000)],
["Last-Modified", http_date(-3000)],
["Expires", 5000],
["Last-Modified", -3000],
["Vary", "Foo"]
],
response_body: http_content('foo_1')
@ -92,8 +92,8 @@
["Foo", "2"]
],
response_headers: [
["Expires", http_date(5000)],
["Last-Modified", http_date(-3000)],
["Expires", 5000],
["Last-Modified", -3000],
["Vary", "Foo"]
],
expected_type: "not_cached",
@ -109,7 +109,7 @@
]
},
{
name: "HTTP cache doesn't pay attention to headers not listed in Vary.",
name: "HTTP cache doesn't pay attention to headers not listed in Vary",
requests: [
{
request_headers: [
@ -117,8 +117,8 @@
["Other", "2"]
],
response_headers: [
["Expires", http_date(5000)],
["Last-Modified", http_date(-3000)],
["Expires", 5000],
["Last-Modified", -3000],
["Vary", "Foo"]
],
},
@ -127,12 +127,12 @@
["Foo", "1"],
["Other", "3"]
],
expected_type: "cached",
expected_type: "cached"
}
]
},
{
name: 'HTTP cache reuses two-way Vary response when request matches.',
name: "HTTP cache reuses two-way Vary response when request matches",
requests: [
{
request_headers: [
@ -140,8 +140,8 @@
["Bar", "abc"]
],
response_headers: [
["Expires", http_date(5000)],
["Last-Modified", http_date(-3000)],
["Expires", 5000],
["Last-Modified", -3000],
["Vary", "Foo, Bar"]
]
},
@ -155,7 +155,7 @@
]
},
{
name: "HTTP cache doesn't use two-way Vary response when request doesn't match.",
name: "HTTP cache doesn't use two-way Vary response when request doesn't match",
requests: [
{
request_headers: [
@ -163,8 +163,8 @@
["Bar", "abc"]
],
response_headers: [
["Expires", http_date(5000)],
["Last-Modified", http_date(-3000)],
["Expires", 5000],
["Last-Modified", -3000],
["Vary", "Foo, Bar"]
]
},
@ -178,15 +178,15 @@
]
},
{
name: "HTTP cache doesn't use two-way Vary response when request omits variant header.",
name: "HTTP cache doesn't use two-way Vary response when request omits variant header",
requests: [
{
request_headers: [
["Foo", "1"]
],
response_headers: [
["Expires", http_date(5000)],
["Last-Modified", http_date(-3000)],
["Expires", 5000],
["Last-Modified", -3000],
["Vary", "Foo, Bar"]
]
},
@ -196,7 +196,7 @@
]
},
{
name: 'HTTP cache reuses three-way Vary response when request matches.',
name: "HTTP cache reuses three-way Vary response when request matches",
requests: [
{
request_headers: [
@ -205,8 +205,8 @@
["Baz", "789"]
],
response_headers: [
["Expires", http_date(5000)],
["Last-Modified", http_date(-3000)],
["Expires", 5000],
["Last-Modified", -3000],
["Vary", "Foo, Bar, Baz"]
]
},
@ -221,7 +221,7 @@
]
},
{
name: "HTTP cache doesn't use three-way Vary response when request doesn't match.",
name: "HTTP cache doesn't use three-way Vary response when request doesn't match",
requests: [
{
request_headers: [
@ -230,8 +230,8 @@
["Baz", "789"]
],
response_headers: [
["Expires", http_date(5000)],
["Last-Modified", http_date(-3000)],
["Expires", 5000],
["Last-Modified", -3000],
["Vary", "Foo, Bar, Baz"]
]
},
@ -246,7 +246,7 @@
]
},
{
name: "HTTP cache doesn't use three-way Vary response when request doesn't match, regardless of header order.",
name: "HTTP cache doesn't use three-way Vary response when request doesn't match, regardless of header order",
requests: [
{
request_headers: [
@ -255,8 +255,8 @@
["Baz", "789"]
],
response_headers: [
["Expires", http_date(5000)],
["Last-Modified", http_date(-3000)],
["Expires", 5000],
["Last-Modified", -3000],
["Vary", "Foo, Bar, Baz"]
]
},
@ -271,7 +271,7 @@
]
},
{
name: "HTTP cache uses three-way Vary response when both request and the original request omited a variant header.",
name: "HTTP cache uses three-way Vary response when both request and the original request omited a variant header",
requests: [
{
request_headers: [
@ -279,8 +279,8 @@
["Baz", "789"]
],
response_headers: [
["Expires", http_date(5000)],
["Last-Modified", http_date(-3000)],
["Expires", 5000],
["Last-Modified", -3000],
["Vary", "Foo, Bar, Baz"]
]
},
@ -294,7 +294,7 @@
]
},
{
name: "HTTP cache doesn't use Vary response with a field value of '*'.",
name: "HTTP cache doesn't use Vary response with a field value of '*'",
requests: [
{
request_headers: [
@ -302,8 +302,8 @@
["Baz", "789"]
],
response_headers: [
["Expires", http_date(5000)],
["Last-Modified", http_date(-3000)],
["Expires", 5000],
["Last-Modified", -3000],
["Vary", "*"]
]
},