more http cache work

This commit is contained in:
Gregory Terzian 2017-08-03 12:17:29 +02:00
parent f36a4fb6d7
commit 2799b4eac9
39 changed files with 798 additions and 2164 deletions

View file

@ -1,106 +0,0 @@
function _oneline(x) {
var i = x.indexOf("\n");
return (i == -1) ? x : (x.slice(0, i) + "...");
}
var _expectations = 0;
var _tests = 0;
function expect(num) {
_expectations = num;
}
function _fail(s, m) {
_tests++;
// string split to avoid problems with tests that end up printing the value of window._fail.
window.alert(_oneline("TEST-UNEXPECTED" + "-FAIL | " + s + ": " + m));
}
function _pass(s, m) {
_tests++;
window.alert(_oneline("TEST-PASS | " + s + ": " + m));
}
function _printer(opstr, op) {
return function (a, b, msg) {
var f = op(a,b) ? _pass : _fail;
if (!msg) msg = "";
f(a + " " + opstr + " " + b, msg);
};
}
var is = _printer("===", function (a,b) { return a === b; });
var is_not = _printer("!==", function (a,b) { return a !== b; });
var is_a = _printer("is a", function (a,b) { return a instanceof b; });
var is_not_a = _printer("is not a", function (a,b) { return !(a instanceof b); });
var is_in = _printer("is in", function (a,b) { return a in b; });
var is_not_in = _printer("is not in", function (a,b) { return !(a in b); });
var as_str_is = _printer("as string is", function (a,b) { return String(a) == b; });
var lt = _printer("<", function (a,b) { return a < b; });
var gt = _printer(">", function (a,b) { return a > b; });
var leq = _printer("<=", function (a,b) { return a <= b; });
var geq = _printer(">=", function (a,b) { return a >= b; });
var starts_with = _printer("starts with", function (a,b) { return a.indexOf(b) == 0; });
function is_function(val, name) {
starts_with(String(val), "function " + name + "(");
}
function should_throw(f) {
try {
f();
_fail("operation should have thrown but did not");
} catch (x) {
_pass("operation successfully threw an exception", x.toString());
}
}
function should_not_throw(f) {
try {
f();
_pass("operation did not throw an exception");
} catch (x) {
_fail("operation should have not thrown", x.toString());
}
}
function check_selector(elem, selector, matches) {
is(elem.matches(selector), matches);
}
function check_disabled_selector(elem, disabled) {
check_selector(elem, ":disabled", disabled);
check_selector(elem, ":enabled", !disabled);
}
var _test_complete = false;
var _test_timeout = 10000; //10 seconds
function finish() {
if (_test_complete) {
_fail('finish called multiple times');
}
if (_expectations > _tests) {
_fail('expected ' + _expectations + ' tests, fullfilled ' + _tests);
}
_test_complete = true;
window.close();
}
function _test_timed_out() {
if (!_test_complete) {
_fail('test timed out (' + _test_timeout/1000 + 's)');
finish();
}
}
setTimeout(_test_timed_out, _test_timeout);
var _needs_finish = false;
function waitForExplicitFinish() {
_needs_finish = true;
}
addEventListener('load', function() {
if (!_needs_finish) {
finish();
}
});

View file

@ -1,25 +0,0 @@
function assert_requests_made(url, n) {
var x = new XMLHttpRequest();
x.open('GET', 'stats?' + url, false);
x.send();
is(parseInt(x.responseText), n, '# of requests for ' + url + ' should be ' + n);
}
function reset_stats() {
var x = new XMLHttpRequest();
x.open('POST', 'reset', false);
x.send();
is(x.status, 200, 'resetting stats should succeed');
}
function fetch(url, headers) {
var x = new XMLHttpRequest();
x.open('GET', url, false);
if (headers) {
for (var i = 0; i < headers.length; i++) {
x.setRequestHeader(headers[i][0], headers[i][1]);
}
}
x.send();
is(x.status, 200, 'fetching ' + url + ' should succeed ');
}

View file

@ -1,2 +0,0 @@
<html>
</html>

View file

@ -1,2 +0,0 @@
<html>
</html>

View file

@ -1,2 +0,0 @@
200
Cache-Control: must-revalidate

View file

@ -1,2 +0,0 @@
<html>
</html>

View file

@ -1,2 +0,0 @@
200
Cache-Control: no-cache

View file

@ -1,14 +0,0 @@
<html>
<head>
<script src="harness.js"></script>
<script src="netharness.js"></script>
</head>
<body>
<script>
reset_stats();
fetch('resources/helper.html');
fetch('resources/helper.html', [['X-User', 'foo']]);
assert_requests_made('resources/helper.html', 2);
</script>
</body>
</html>

View file

@ -1,14 +0,0 @@
<html>
<head>
<script src="harness.js"></script>
<script src="netharness.js"></script>
</head>
<body>
<script>
reset_stats();
fetch('resources/helper.html');
fetch('resources/helper.html');
assert_requests_made('resources/helper.html', 1);
</script>
</body>
</html>

View file

@ -1,30 +0,0 @@
<!doctype html>
<html>
<head>
<title></title>
<script src="harness.js"></script>
<script>
// test1: URL & documentURI
{
is_not(document.URL, null, "test1-0, URL & documentURI");
is_not(document.documentURI, null, "test1-1, URL & documentURI");
is(document.URL, document.documentURI, "test1-2, URL & documentURI");
}
// test2: new document
{
var doc = new Document();
is(doc.URL, "about:blank", "test2-0, new document");
}
// test3: current document
{
var url = document.URL.split("/");
is(url[0], "http:", "test3-0, current document");
is(url[url.length-1], "test_document_url.html", "test3-1, current document");
}
</script>
</head>
<body>
</body>
</html>

View file

@ -1,14 +0,0 @@
<html>
<head>
<script src="harness.js"></script>
<script src="netharness.js"></script>
</head>
<body>
<script>
reset_stats();
fetch('resources/helper_nocache.html');
fetch('resources/helper_nocache.html');
assert_requests_made('resources/helper_nocache.html', 2);
</script>
</body>
</html>

View file

@ -1,14 +0,0 @@
<html>
<head>
<script src="harness.js"></script>
<script src="netharness.js"></script>
</head>
<body>
<script>
reset_stats();
fetch('resources/helper_must_revalidate.html');
fetch('resources/helper_must_revalidate.html');
assert_requests_made('resources/helper_must_revalidate.html', 1);
</script>
</body>
</html>

194
tests/contenttest.rs vendored
View file

@ -1,194 +0,0 @@
// Copyright 2013 The Servo Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![deny(unused_imports)]
#![deny(unused_variables)]
extern crate getopts;
extern crate regex;
extern crate test;
use test::{AutoColor, TestOpts, run_tests_console, TestDesc, TestDescAndFn, DynTestFn, DynTestName};
use getopts::{getopts, reqopt};
use std::comm::channel;
use std::from_str::FromStr;
use std::{os, str};
use std::io::fs;
use std::io::Reader;
use std::io::process::{Command, Ignored, CreatePipe, InheritFd, ExitStatus};
use std::task;
use regex::Regex;
#[deriving(Clone)]
struct Config {
source_dir: String,
filter: Option<Regex>
}
fn main() {
let args = os::args();
let config = parse_config(args.into_iter().collect());
let opts = test_options(&config);
let tests = find_tests(&config);
match run_tests_console(&opts, tests) {
Ok(false) => os::set_exit_status(1), // tests failed
Err(_) => os::set_exit_status(2), // I/O-related failure
_ => (),
}
}
enum ServerMsg {
IsAlive(Sender<bool>),
Exit,
}
fn run_http_server(source_dir: String) -> (Sender<ServerMsg>, u16) {
let (tx, rx) = channel();
let (port_sender, port_receiver) = channel();
task::spawn(proc() {
let mut prc = Command::new("python")
.args(["../httpserver.py"])
.stdin(Ignored)
.stdout(CreatePipe(false, true))
.stderr(Ignored)
.cwd(&Path::new(source_dir))
.spawn()
.ok()
.expect("Unable to spawn server.");
let mut bytes = vec!();
loop {
let byte = prc.stdout.as_mut().unwrap().read_byte().unwrap();
if byte == '\n' as u8 {
break;
} else {
bytes.push(byte);
}
}
let mut words = str::from_utf8(bytes.as_slice()).unwrap().split(' ');
let port = FromStr::from_str(words.last().unwrap()).unwrap();
port_sender.send(port);
loop {
match rx.recv() {
IsAlive(reply) => reply.send(prc.signal(0).is_ok()),
Exit => {
let _ = prc.signal_exit();
break;
}
}
}
});
(tx, port_receiver.recv())
}
fn parse_config(args: Vec<String>) -> Config {
let args = args.tail();
let opts = vec!(reqopt("s", "source-dir", "source-dir", "source-dir"));
let matches = match getopts(args, opts.as_slice()) {
Ok(m) => m,
Err(f) => panic!(format!("{}", f))
};
Config {
source_dir: matches.opt_str("source-dir").unwrap(),
filter: matches.free.as_slice().head().map(|s| Regex::new(s.as_slice()).unwrap())
}
}
fn test_options(config: &Config) -> TestOpts {
TestOpts {
filter: config.filter.clone(),
run_ignored: false,
run_tests: true,
run_benchmarks: false,
ratchet_metrics: None,
ratchet_noise_percent: None,
save_metrics: None,
test_shard: None,
logfile: None,
nocapture: false,
color: AutoColor
}
}
fn find_tests(config: &Config) -> Vec<TestDescAndFn> {
let files_res = fs::readdir(&Path::new(config.source_dir.clone()));
let mut files = match files_res {
Ok(files) => files,
_ => panic!("Error reading directory."),
};
files.retain(|file| file.extension_str() == Some("html") );
return files.iter().map(|file| make_test(format!("{}", file.display()),
config.source_dir.clone())).collect();
}
fn make_test(file: String, source_dir: String) -> TestDescAndFn {
TestDescAndFn {
desc: TestDesc {
name: DynTestName(file.clone()),
ignore: false,
should_fail: false
},
testfn: DynTestFn(proc() { run_test(file, source_dir) })
}
}
fn run_test(file: String, source_dir: String) {
let (server, port) = run_http_server(source_dir);
let path = os::make_absolute(&Path::new(file));
// FIXME (#1094): not the right way to transform a path
let infile = format!("http://localhost:{}/{}", port, path.filename_display());
let stdout = CreatePipe(false, true);
let stderr = InheritFd(2);
let args = ["-z", "-f", infile.as_slice()];
let (tx, rx) = channel();
server.send(IsAlive(tx));
assert!(rx.recv(), "HTTP server must be running.");
let mut prc = match Command::new("target/servo")
.args(args)
.stdin(Ignored)
.stdout(stdout)
.stderr(stderr)
.spawn()
{
Ok(p) => p,
_ => panic!("Unable to spawn process."),
};
let mut output = Vec::new();
loop {
let byte = prc.stdout.as_mut().unwrap().read_byte();
match byte {
Ok(byte) => {
print!("{}", byte as char);
output.push(byte);
}
_ => break
}
}
server.send(Exit);
let out = str::from_utf8(output.as_slice());
let lines: Vec<&str> = out.unwrap().split('\n').collect();
for &line in lines.iter() {
if line.contains("TEST-UNEXPECTED-FAIL") {
panic!(line.to_string());
}
}
let retval = prc.wait();
if retval != Ok(ExitStatus(0)) {
panic!("Servo exited with non-zero status {}", retval);
}
}

115
tests/httpserver.py vendored
View file

@ -1,115 +0,0 @@
from SimpleHTTPServer import SimpleHTTPRequestHandler
import SocketServer
import os
import sys
from collections import defaultdict
PORT = int(sys.argv[1]) if len(sys.argv) > 1 else 0
requests = defaultdict(int)
class CountingRequestHandler(SimpleHTTPRequestHandler):
def __init__(self, req, client_addr, server):
SimpleHTTPRequestHandler.__init__(self, req, client_addr, server)
def do_POST(self):
global requests
parts = self.path.split('/')
if parts[1] == 'reset':
requests = defaultdict(int)
self.send_response(200)
self.send_header('Content-Type', 'text/plain')
self.send_header('Content-Length', 0)
self.end_headers()
self.wfile.write('')
return
def do_GET(self):
global requests
parts = self.path.split('?')
if parts[0] == '/stats':
self.send_response(200)
self.send_header('Content-Type', 'text/plain')
if len(parts) > 1:
body = str(requests['/' + parts[1]])
else:
body = ''
for key, value in requests.iteritems():
body += key + ': ' + str(value) + '\n'
self.send_header('Content-Length', len(body))
self.end_headers()
self.wfile.write(body)
return
header_list = []
status = None
path = self.translate_path(self.path)
headers = path + '^headers'
if os.path.isfile(headers):
try:
h = open(headers, 'rb')
except IOError:
self.send_error(404, "Header file not found")
return
header_lines = h.readlines()
status = int(header_lines[0])
for header in header_lines[1:]:
parts = map(lambda x: x.strip(), header.split(':'))
header_list += [parts]
if self.headers.get('If-Modified-Since'):
self.send_response(304)
self.end_headers()
return
if not status or status == 200:
requests[self.path] += 1
if status or header_list:
ctype = self.guess_type(path)
try:
# Always read in binary mode. Opening files in text mode may cause
# newline translations, making the actual size of the content
# transmitted *less* than the content-length!
f = open(path, 'rb')
except IOError:
self.send_error(404, "File not found")
return
try:
self.send_response(status or 200)
self.send_header("Content-type", ctype)
fs = os.fstat(f.fileno())
self.send_header("Content-Length", str(fs[6]))
self.send_header("Last-Modified", self.date_time_string(fs.st_mtime))
for header in header_list:
self.send_header(header[0], header[1])
self.end_headers()
try:
self.copyfile(f, self.wfile)
finally:
f.close()
except:
f.close()
raise
else:
SimpleHTTPRequestHandler.do_GET(self)
class MyTCPServer(SocketServer.TCPServer):
request_queue_size = 2000
allow_reuse_address = True
httpd = MyTCPServer(("", PORT), CountingRequestHandler)
if not PORT:
ip, PORT = httpd.server_address
print "serving at port", PORT
sys.stdout.flush()
httpd.serve_forever()

View file

@ -524761,7 +524761,7 @@
"support"
],
"fetch/http-cache/cc-request.html": [
"d4417b8fd444362a3f217d1c95d37811a608e1a7",
"2002d341679139428e164cfe916dd39b9b664a3e",
"testharness"
],
"fetch/http-cache/freshness.html": [
@ -524769,7 +524769,7 @@
"testharness"
],
"fetch/http-cache/heuristic.html": [
"5b0d55f891cb2e235456cd65f4e9f63e07999410",
"63837026eb6085fc7d6220c3dcab200b4bcd1eca",
"testharness"
],
"fetch/http-cache/http-cache.js": [
@ -524781,7 +524781,7 @@
"testharness"
],
"fetch/http-cache/partial.html": [
"243e57c39f9e45e3e2acf845b36f3a140e3763bc",
"685057fe8876321a5d42bcf1e7582e6f0b745f85",
"testharness"
],
"fetch/http-cache/resources/http-cache.py": [
@ -524793,7 +524793,7 @@
"testharness"
],
"fetch/http-cache/vary.html": [
"fa9a2e0554671bf2de5826e66ac0ea73de28d530",
"45f337270cfa90932c7469802655e313367ac92f",
"testharness"
],
"fetch/nosniff/image.html": [

View file

@ -1,14 +0,0 @@
[304.htm]
type: testharness
[A 304 response with no CORS headers inherits from the stored response]
expected: FAIL
[A 304 can expand Access-Control-Expose-Headers]
expected: FAIL
[A 304 can contract Access-Control-Expose-Headers]
expected: FAIL
[A 304 can change Access-Control-Allow-Origin]
expected: FAIL

View file

@ -1,3 +0,0 @@
[request-cache-default-conditional.html]
type: testharness
disabled: https://github.com/servo/servo/issues/13441

View file

@ -1,11 +0,0 @@
[request-cache-default.html]
type: testharness
[RequestCache "default" mode checks the cache for previously cached content and avoids going to the network if a fresh response exists with Etag and fresh response]
expected: FAIL
[RequestCache "default" mode checks the cache for previously cached content and avoids going to the network if a fresh response exists with date and fresh response]
expected: FAIL
[RequestCache "default" mode checks the cache for previously cached content and avoids going to the network if a fresh response exists with Last-Modified and fresh response]
expected: FAIL

View file

@ -1,29 +0,0 @@
[request-cache-force-cache.html]
type: testharness
[RequestCache "force-cache" mode checks the cache for previously cached content and avoid revalidation for stale responses with Etag and stale response]
expected: FAIL
[RequestCache "force-cache" mode checks the cache for previously cached content and avoid revalidation for stale responses with date and stale response]
expected: FAIL
[RequestCache "force-cache" mode checks the cache for previously cached content and avoid revalidation for fresh responses with Etag and fresh response]
expected: FAIL
[RequestCache "force-cache" mode checks the cache for previously cached content and avoid revalidation for fresh responses with date and fresh response]
expected: FAIL
[RequestCache "force-cache" stores the response in the cache if it goes to the network with Etag and fresh response]
expected: FAIL
[RequestCache "force-cache" stores the response in the cache if it goes to the network with date and fresh response]
expected: FAIL
[RequestCache "force-cache" mode checks the cache for previously cached content and avoid revalidation for stale responses with Last-Modified and stale response]
expected: FAIL
[RequestCache "force-cache" mode checks the cache for previously cached content and avoid revalidation for fresh responses with Last-Modified and fresh response]
expected: FAIL
[RequestCache "force-cache" stores the response in the cache if it goes to the network with Last-Modified and fresh response]
expected: FAIL

View file

@ -1,65 +0,0 @@
[request-cache-only-if-cached.html]
type: testharness
[RequestCache "only-if-cached" mode checks the cache for previously cached content and avoids revalidation for stale responses with Etag and stale response]
expected: FAIL
[RequestCache "only-if-cached" mode checks the cache for previously cached content and avoids revalidation for stale responses with date and stale response]
expected: FAIL
[RequestCache "only-if-cached" mode checks the cache for previously cached content and avoids revalidation for fresh responses with Etag and fresh response]
expected: FAIL
[RequestCache "only-if-cached" mode checks the cache for previously cached content and avoids revalidation for fresh responses with date and fresh response]
expected: FAIL
[RequestCache "only-if-cached" mode checks the cache for previously cached content and does not go to the network if a cached response is not found with Etag and fresh response]
expected: FAIL
[RequestCache "only-if-cached" mode checks the cache for previously cached content and does not go to the network if a cached response is not found with date and fresh response]
expected: FAIL
[RequestCache "only-if-cached" (with "same-origin") uses cached same-origin redirects to same-origin content with Etag and fresh response]
expected: FAIL
[RequestCache "only-if-cached" (with "same-origin") uses cached same-origin redirects to same-origin content with date and fresh response]
expected: FAIL
[RequestCache "only-if-cached" (with "same-origin") uses cached same-origin redirects to same-origin content with Etag and stale response]
expected: FAIL
[RequestCache "only-if-cached" (with "same-origin") uses cached same-origin redirects to same-origin content with date and stale response]
expected: FAIL
[RequestCache "only-if-cached" (with "same-origin") does not follow redirects across origins and rejects with Etag and fresh response]
expected: FAIL
[RequestCache "only-if-cached" (with "same-origin") does not follow redirects across origins and rejects with date and fresh response]
expected: FAIL
[RequestCache "only-if-cached" (with "same-origin") does not follow redirects across origins and rejects with Etag and stale response]
expected: FAIL
[RequestCache "only-if-cached" (with "same-origin") does not follow redirects across origins and rejects with date and stale response]
expected: FAIL
[RequestCache "only-if-cached" mode checks the cache for previously cached content and avoids revalidation for stale responses with Last-Modified and stale response]
expected: FAIL
[RequestCache "only-if-cached" mode checks the cache for previously cached content and avoids revalidation for fresh responses with Last-Modified and fresh response]
expected: FAIL
[RequestCache "only-if-cached" mode checks the cache for previously cached content and does not go to the network if a cached response is not found with Last-Modified and fresh response]
expected: FAIL
[RequestCache "only-if-cached" (with "same-origin") uses cached same-origin redirects to same-origin content with Last-Modified and fresh response]
expected: FAIL
[RequestCache "only-if-cached" (with "same-origin") uses cached same-origin redirects to same-origin content with Last-Modified and stale response]
expected: FAIL
[RequestCache "only-if-cached" (with "same-origin") does not follow redirects across origins and rejects with Last-Modified and fresh response]
expected: FAIL
[RequestCache "only-if-cached" (with "same-origin") does not follow redirects across origins and rejects with Last-Modified and stale response]
expected: FAIL

View file

@ -1,20 +0,0 @@
[request-cache-reload.html]
type: testharness
[RequestCache "reload" mode does store the response in the cache with Etag and fresh response]
expected: FAIL
[RequestCache "reload" mode does store the response in the cache with date and fresh response]
expected: FAIL
[RequestCache "reload" mode does store the response in the cache even if a previous response is already stored with Etag and fresh response]
expected: FAIL
[RequestCache "reload" mode does store the response in the cache even if a previous response is already stored with date and fresh response]
expected: FAIL
[RequestCache "reload" mode does store the response in the cache with Last-Modified and fresh response]
expected: FAIL
[RequestCache "reload" mode does store the response in the cache even if a previous response is already stored with Last-Modified and fresh response]
expected: FAIL

View file

@ -1,14 +0,0 @@
[304-update.html]
type: testharness
[HTTP cache updates returned headers from a Last-Modified 304.]
expected: FAIL
[HTTP cache updates stored headers from a Last-Modified 304.]
expected: FAIL
[HTTP cache updates returned headers from a ETag 304.]
expected: FAIL
[HTTP cache updates stored headers from a ETag 304.]
expected: FAIL

View file

@ -1,11 +1,5 @@
[cc-request.html]
type: testharness
[HTTP cache does use aged stale response when request contains Cache-Control: max-stale that permits its use.]
expected: FAIL
[HTTP cache does reuse stale response with Age header when request contains Cache-Control: max-stale that permits its use.]
expected: FAIL
[HTTP cache generates 504 status code when nothing is in cache and request contains Cache-Control: only-if-cached.]
expected: FAIL

View file

@ -1,20 +0,0 @@
[freshness.html]
type: testharness
[HTTP cache reuses a response with a future Expires.]
expected: FAIL
[HTTP cache reuses a response with positive Cache-Control: max-age.]
expected: FAIL
[HTTP cache reuses a response with positive Cache-Control: max-age and a past Expires.]
expected: FAIL
[HTTP cache reuses a response with positive Cache-Control: max-age and an invalid Expires.]
expected: FAIL
[HTTP cache stores a response with Cache-Control: no-cache, but revalidates upon use.]
expected: FAIL
[HTTP cache stores a response with Cache-Control: no-cache, but revalidates upon use, even with max-age and Expires.]
expected: FAIL

View file

@ -1,29 +0,0 @@
[heuristic.html]
type: testharness
[HTTP cache reuses an unknown response with Last-Modified based upon heuristic freshness when Cache-Control: public is present.]
expected: FAIL
[HTTP cache reuses a 200 OK response with Last-Modified based upon heuristic freshness.]
expected: FAIL
[HTTP cache reuses a 203 Non-Authoritative Information response with Last-Modified based upon heuristic freshness.]
expected: FAIL
[HTTP cache reuses a 204 No Content response with Last-Modified based upon heuristic freshness.]
expected: FAIL
[HTTP cache reuses a 404 Not Found response with Last-Modified based upon heuristic freshness.]
expected: FAIL
[HTTP cache reuses a 405 Method Not Allowed response with Last-Modified based upon heuristic freshness.]
expected: FAIL
[HTTP cache reuses a 410 Gone response with Last-Modified based upon heuristic freshness.]
expected: FAIL
[HTTP cache reuses a 414 URI Too Long response with Last-Modified based upon heuristic freshness.]
expected: FAIL
[HTTP cache reuses a 501 Not Implemented response with Last-Modified based upon heuristic freshness.]
expected: FAIL

View file

@ -1,20 +1,11 @@
[invalidate.html]
type: testharness
[HTTP cache does not invalidate after a failed response from an unsafe request]
expected: FAIL
[HTTP cache invalidates after a successful response from an unknown method]
expected: FAIL
[HTTP cache does not invalidate Location URL after a failed response from an unsafe request]
expected: FAIL
[HTTP cache invalidates Location URL after a successful response from an unknown method]
expected: FAIL
[HTTP cache does not invalidate Content-Location URL after a failed response from an unsafe request]
expected: FAIL
[HTTP cache invalidates Content-Location URL after a successful response from an unknown method]
expected: FAIL

View file

@ -1,13 +1,5 @@
[partial.html]
type: testharness
[HTTP cache stores partial content and reuses it.]
expected: FAIL
[HTTP cache stores complete response and serves smaller ranges from it.]
expected: FAIL
[HTTP cache stores partial response and serves smaller ranges from it.]
expected: FAIL
[HTTP cache stores partial content and completes it.]
expected: FAIL

View file

@ -1,41 +0,0 @@
[status.html]
type: testharness
[HTTP cache avoids going to the network if it has a fresh 200 response.]
expected: FAIL
[HTTP cache avoids going to the network if it has a fresh 203 response.]
expected: FAIL
[HTTP cache avoids going to the network if it has a fresh 204 response.]
expected: FAIL
[HTTP cache avoids going to the network if it has a fresh 299 response.]
expected: FAIL
[HTTP cache avoids going to the network if it has a fresh 400 response.]
expected: FAIL
[HTTP cache avoids going to the network if it has a fresh 404 response.]
expected: FAIL
[HTTP cache avoids going to the network if it has a fresh 410 response.]
expected: FAIL
[HTTP cache avoids going to the network if it has a fresh 499 response.]
expected: FAIL
[HTTP cache avoids going to the network if it has a fresh 500 response.]
expected: FAIL
[HTTP cache avoids going to the network if it has a fresh 502 response.]
expected: FAIL
[HTTP cache avoids going to the network if it has a fresh 503 response.]
expected: FAIL
[HTTP cache avoids going to the network if it has a fresh 504 response.]
expected: FAIL
[HTTP cache avoids going to the network if it has a fresh 599 response.]
expected: FAIL

View file

@ -1,17 +0,0 @@
[vary.html]
type: testharness
[HTTP cache reuses Vary response when request matches.]
expected: FAIL
[HTTP cache doesn't invalidate existing Vary response.]
expected: FAIL
[HTTP cache doesn't pay attention to headers not listed in Vary.]
expected: FAIL
[HTTP cache reuses two-way Vary response when request matches.]
expected: FAIL
[HTTP cache reuses three-way Vary response when request matches.]
expected: FAIL

View file

@ -201,7 +201,8 @@
request_headers: [
["Cache-Control", "only-if-cached"]
],
expected_status: 504
expected_status: 504,
expected_response_text: ""
}
]
}

View file

@ -26,6 +26,7 @@
},
{
expected_type: "cached",
response_status: [299, "Whatever"],
}
]
},
@ -35,8 +36,7 @@
{
response_status: [299, "Whatever"],
response_headers: [
['Last-Modified', http_date(-3 * 100)],
['Cache-Control', 'public']
['Last-Modified', http_date(-3 * 100)]
],
},
{

View file

@ -24,7 +24,7 @@
response_status: [206, "Partial Content"],
response_headers: [
['Cache-Control', 'max-age=3600'],
['Content-Range', 'bytes 0-4/10']
['Content-Range', 'bytes 4-9/10']
],
response_body: "01234",
expected_request_headers: [
@ -36,12 +36,13 @@
['Range', "bytes=-5"]
],
expected_type: "cached",
expected_status: 206
expected_status: 206,
expected_response_text: "01234"
}
]
},
{
name: 'HTTP cache stores complete response and serves smaller ranges from it.',
name: 'HTTP cache stores complete response and serves smaller ranges from it(byte-range-spec).',
requests: [
{
response_headers: [
@ -51,15 +52,54 @@
},
{
request_headers: [
['Range', "bytes=-1"]
['Range', "bytes=0-1"]
],
expected_type: "cached",
expected_status: 206,
expected_response_text: "01"
},
]
},
{
name: 'HTTP cache stores complete response and serves smaller ranges from it(absent last-byte-pos).',
requests: [
{
response_headers: [
['Cache-Control', 'max-age=3600'],
],
response_body: "01234567890",
},
{
request_headers: [
['Range', "bytes=1-"]
],
expected_type: "cached",
expected_status: 206,
expected_response_text: "1234567890"
}
]
},
{
name: 'HTTP cache stores partial response and serves smaller ranges from it.',
name: 'HTTP cache stores complete response and serves smaller ranges from it(suffix-byte-range-spec).',
requests: [
{
response_headers: [
['Cache-Control', 'max-age=3600'],
],
response_body: "0123456789A",
},
{
request_headers: [
['Range', "bytes=-1"]
],
expected_type: "cached",
expected_status: 206,
expected_response_text: "A"
}
]
},
{
name: 'HTTP cache stores partial response and serves smaller ranges from it(byte-range-spec).',
requests: [
{
request_headers: [
@ -68,7 +108,55 @@
response_status: [206, "Partial Content"],
response_headers: [
['Cache-Control', 'max-age=3600'],
['Content-Range', 'bytes 0-4/10']
['Content-Range', 'bytes 4-9/10']
],
response_body: "01234",
},
{
request_headers: [
['Range', "bytes=6-8"]
],
expected_type: "cached",
expected_status: 206,
expected_response_text: "234"
}
]
},
{
name: 'HTTP cache stores partial response and serves smaller ranges from it(absent last-byte-pos).',
requests: [
{
request_headers: [
['Range', "bytes=-5"]
],
response_status: [206, "Partial Content"],
response_headers: [
['Cache-Control', 'max-age=3600'],
['Content-Range', 'bytes 4-9/10']
],
response_body: "01234",
},
{
request_headers: [
['Range', "bytes=6-"]
],
expected_type: "cached",
expected_status: 206,
expected_response_text: "234"
}
]
},
{
name: 'HTTP cache stores partial response and serves smaller ranges from it(suffix-byte-range-spec).',
requests: [
{
request_headers: [
['Range', "bytes=-5"]
],
response_status: [206, "Partial Content"],
response_headers: [
['Cache-Control', 'max-age=3600'],
['Content-Range', 'bytes 4-9/10']
],
response_body: "01234",
},
@ -77,7 +165,8 @@
['Range', "bytes=-1"]
],
expected_type: "cached",
expected_response_text: "01"
expected_status: 206,
expected_response_text: "4"
}
]
},

View file

@ -103,6 +103,7 @@
request_headers: [
["Foo", "1"]
],
response_body: http_content('foo_1'),
expected_type: "cached"
}
]
@ -245,7 +246,32 @@
]
},
{
name: "HTTP cache doesn't use three-way Vary response when request omits variant header.",
name: "HTTP cache doesn't use three-way Vary response when request doesn't match, regardless of header order.",
requests: [
{
request_headers: [
["Foo", "1"],
["Bar", "abc4"],
["Baz", "789"]
],
response_headers: [
["Expires", http_date(5000)],
["Last-Modified", http_date(-3000)],
["Vary", "Foo, Bar, Baz"]
]
},
{
request_headers: [
["Foo", "1"],
["Bar", "abc"],
["Baz", "789"]
],
expected_type: "not_cached"
}
]
},
{
name: "HTTP cache uses three-way Vary response when both request and the original request omited a variant header.",
requests: [
{
request_headers: [
@ -259,6 +285,33 @@
]
},
{
request_headers: [
["Foo", "1"],
["Baz", "789"]
],
expected_type: "cached"
}
]
},
{
name: "HTTP cache doesn't use Vary response with a field value of '*'.",
requests: [
{
request_headers: [
["Foo", "1"],
["Baz", "789"]
],
response_headers: [
["Expires", http_date(5000)],
["Last-Modified", http_date(-3000)],
["Vary", "*"]
]
},
{
request_headers: [
["*", "1"],
["Baz", "789"]
],
expected_type: "not_cached"
}
]