-
Notifications
You must be signed in to change notification settings - Fork 21
/
updateHead.mjs
109 lines (107 loc) · 2.85 KB
/
updateHead.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
import * as templates from './lib/templates.mjs'
export default
{
name: 'HEAD updates',
id: 'updateHEAD',
description: 'These tests check how a cache updates stored responses when receiving a `HEAD` response.',
spec_anchors: ['head.effects'],
tests: [
{
name: 'Does HTTP cache write through a HEAD when stored response is stale?',
id: 'head-writethrough',
kind: 'check',
depends_on: ['freshness-max-age-stale'],
requests: [
templates.becomeStale({}),
{
request_method: 'HEAD',
expected_method: 'HEAD'
}
]
},
{
name: 'Does HTTP cache preserve stored fields not received in a `200` response to a `HEAD`?',
id: 'head-200-retain',
kind: 'check',
depends_on: ['head-writethrough'],
requests: [
templates.becomeStale({}),
{
request_method: 'HEAD',
expected_method: 'HEAD',
expected_response_headers: [
['Template-A', '1']
]
}
]
},
{
name: 'Does HTTP cache update freshness lifetime recieved in a `200` response to a `HEAD`?',
id: 'head-200-freshness-update',
kind: 'check',
depends_on: ['head-writethrough'],
requests: [
templates.becomeStale({}),
{
request_method: 'HEAD',
expected_method: 'HEAD',
response_headers: [
['Cache-Control', 'max-age=1000']
]
},
{
expected_type: 'cached'
}
]
},
{
name: 'Does HTTP cache update stored fields recieved in a `200` response to a `HEAD`?',
id: 'head-200-update',
kind: 'check',
depends_on: ['head-200-freshness-update'],
requests: [
templates.becomeStale({}),
{
request_method: 'HEAD',
expected_method: 'HEAD',
response_headers: [
['Template-A', '2'],
['Cache-Control', 'max-age=1000']
]
},
{
expected_type: 'cached',
setup_tests: ['expected_type'],
expected_response_headers: [
['Template-A', '2']
]
}
]
},
{
name: 'Does HTTP cache update stored fields recieved in a `410` response to a `HEAD`?',
id: 'head-410-update',
kind: 'check',
depends_on: ['head-200-freshness-update'],
requests: [
templates.becomeStale({}),
{
request_method: 'HEAD',
expected_method: 'HEAD',
response_status: [410, 'Gone'],
response_headers: [
['Template-A', '2'],
['Cache-Control', 'max-age=1000']
]
},
{
expected_type: 'cached',
setup_tests: ['expected_type'],
expected_response_headers: [
['Template-A', '2']
]
}
]
}
]
}