OLD | NEW |
(Empty) | |
| 1 <!doctype html> |
| 2 <html> |
| 3 <head> |
| 4 <meta charset="utf-8"> |
| 5 <title>HTTP Cache - Status Codes</title> |
| 6 <meta name="help" href="https://fetch.spec.whatwg.org/#request"> |
| 7 <script src="/resources/testharness.js"></script> |
| 8 <script src="/resources/testharnessreport.js"></script> |
| 9 <script src="/common/utils.js"></script> |
| 10 <script src="/common/get-host-info.sub.js"></script> |
| 11 <script src="http-cache.js"></script> |
| 12 </head> |
| 13 <body> |
| 14 <script> |
| 15 var tests = []; |
| 16 function check_status(status) { |
| 17 var code = status[0]; |
| 18 var phrase = status[1]; |
| 19 var body = status[2]; |
| 20 if (body === undefined) { |
| 21 body = http_content(code); |
| 22 } |
| 23 tests.push({ |
| 24 name: 'HTTP cache goes to the network if it has a stale ' + code + ' res
ponse.', |
| 25 requests: [ |
| 26 { |
| 27 template: "stale", |
| 28 response_status: [code, phrase], |
| 29 response_body: body |
| 30 }, { |
| 31 expected_type: "not_cached", |
| 32 response_body: body |
| 33 } |
| 34 ] |
| 35 }) |
| 36 tests.push({ |
| 37 name: 'HTTP cache avoids going to the network if it has a fresh ' + code
+ ' response.', |
| 38 requests: [ |
| 39 { |
| 40 template: "fresh", |
| 41 response_status: [code, phrase], |
| 42 response_body: body |
| 43 }, { |
| 44 expected_type: "cached", |
| 45 response_status: [code, phrase], |
| 46 response_body: body |
| 47 } |
| 48 ] |
| 49 }) |
| 50 } |
| 51 [ |
| 52 [200, 'OK'], |
| 53 [203, "Non-Authoritative Information"], |
| 54 [204, "No Content", ""], |
| 55 [299, "Whatever"], |
| 56 [400, "Bad Request"], |
| 57 [404, "Not Found"], |
| 58 [410, "Gone"], |
| 59 [499, "Whatever"], |
| 60 [500, "Internal Server Error"], |
| 61 [502, "Bad Gateway"], |
| 62 [503, "Service Unavailable"], |
| 63 [504, "Gateway Timeout"], |
| 64 [599, "Whatever"] |
| 65 ].forEach(check_status); |
| 66 run_tests(tests); |
| 67 </script> |
| 68 </body> |
| 69 </html> |
OLD | NEW |