Skip to content

Commit d57c8fb

Browse files
committed
More HTTP stuff
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
1 parent 84b18be commit d57c8fb

10 files changed

Lines changed: 1199 additions & 0 deletions

File tree

schemas/ietf/http/etag-strong.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"title": "RFC 9110 HTTP Strong ETag",
4+
"description": "A strong HTTP entity tag used for cache validation",
5+
"$comment": "https://www.rfc-editor.org/rfc/rfc9110#section-8.8.3",
6+
"examples": [ "\"abc123\"", "\"686897696a7c876b7e\"", "\"\"" ],
7+
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
8+
"type": "string",
9+
"pattern": "^\"[\\x21\\x23-\\x7E\\x80-\\xFF]*\"$"
10+
}

schemas/ietf/http/etag-weak.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"title": "RFC 9110 HTTP Weak ETag",
4+
"description": "A weak HTTP entity tag used for cache validation with relaxed comparison semantics",
5+
"$comment": "https://www.rfc-editor.org/rfc/rfc9110#section-8.8.3",
6+
"examples": [ "W/\"abc123\"", "W/\"686897696a7c876b7e\"", "W/\"\"" ],
7+
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
8+
"type": "string",
9+
"pattern": "^W/\"[\\x21\\x23-\\x7E\\x80-\\xFF]*\"$"
10+
}

schemas/ietf/http/etag.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"title": "RFC 9110 HTTP ETag",
4+
"description": "An HTTP entity tag used for cache validation, either strong or weak",
5+
"$comment": "https://www.rfc-editor.org/rfc/rfc9110#section-8.8.3",
6+
"examples": [ "\"abc123\"", "W/\"abc123\"", "\"\"" ],
7+
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
8+
"anyOf": [
9+
{
10+
"$ref": "./etag-strong.json"
11+
},
12+
{
13+
"$ref": "./etag-weak.json"
14+
}
15+
]
16+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"title": "RFC 9110 HTTP Standard Method",
4+
"description": "An HTTP request method explicitly defined in RFC 9110 section 9 (case-sensitive)",
5+
"$comment": "https://www.rfc-editor.org/rfc/rfc9110#section-9.3",
6+
"examples": [ "GET", "POST", "PUT" ],
7+
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
8+
"enum": [
9+
"GET",
10+
"HEAD",
11+
"POST",
12+
"PUT",
13+
"DELETE",
14+
"CONNECT",
15+
"OPTIONS",
16+
"TRACE"
17+
]
18+
}

schemas/ietf/http/method.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"title": "RFC 9110 HTTP Method",
4+
"description": "An HTTP request method token",
5+
"$comment": "https://www.rfc-editor.org/rfc/rfc9110#section-9",
6+
"examples": [ "GET", "POST", "PUT", "PATCH" ],
7+
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
8+
"type": "string",
9+
"pattern": "^[!#$%&'*+\\-.0-9A-Z^_`a-z|~]+$"
10+
}
Lines changed: 261 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,261 @@
1+
{
2+
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
3+
"target": "../../../schemas/ietf/http/etag-strong.json",
4+
"tests": [
5+
{
6+
"description": "Invalid type - number",
7+
"data": 123,
8+
"valid": false
9+
},
10+
{
11+
"description": "Invalid type - boolean",
12+
"data": true,
13+
"valid": false
14+
},
15+
{
16+
"description": "Invalid type - null",
17+
"data": null,
18+
"valid": false
19+
},
20+
{
21+
"description": "Invalid type - array",
22+
"data": [],
23+
"valid": false
24+
},
25+
{
26+
"description": "Invalid type - object",
27+
"data": {},
28+
"valid": false
29+
},
30+
{
31+
"description": "Valid - empty strong ETag",
32+
"data": "\"\"",
33+
"valid": true
34+
},
35+
{
36+
"description": "Valid - simple alphanumeric",
37+
"data": "\"abc123\"",
38+
"valid": true
39+
},
40+
{
41+
"description": "Valid - hex string",
42+
"data": "\"686897696a7c876b7e\"",
43+
"valid": true
44+
},
45+
{
46+
"description": "Valid - with hyphens",
47+
"data": "\"abc-123-def\"",
48+
"valid": true
49+
},
50+
{
51+
"description": "Valid - with underscores",
52+
"data": "\"abc_123_def\"",
53+
"valid": true
54+
},
55+
{
56+
"description": "Valid - with dots",
57+
"data": "\"version.1.2.3\"",
58+
"valid": true
59+
},
60+
{
61+
"description": "Valid - with exclamation mark",
62+
"data": "\"abc!123\"",
63+
"valid": true
64+
},
65+
{
66+
"description": "Valid - with hash",
67+
"data": "\"#abc123\"",
68+
"valid": true
69+
},
70+
{
71+
"description": "Valid - with dollar sign",
72+
"data": "\"$abc123\"",
73+
"valid": true
74+
},
75+
{
76+
"description": "Valid - with percent",
77+
"data": "\"abc%123\"",
78+
"valid": true
79+
},
80+
{
81+
"description": "Valid - with ampersand",
82+
"data": "\"abc&123\"",
83+
"valid": true
84+
},
85+
{
86+
"description": "Valid - with asterisk",
87+
"data": "\"abc*123\"",
88+
"valid": true
89+
},
90+
{
91+
"description": "Valid - with plus",
92+
"data": "\"abc+123\"",
93+
"valid": true
94+
},
95+
{
96+
"description": "Valid - with forward slash",
97+
"data": "\"abc/123\"",
98+
"valid": true
99+
},
100+
{
101+
"description": "Valid - with colon",
102+
"data": "\"abc:123\"",
103+
"valid": true
104+
},
105+
{
106+
"description": "Valid - with semicolon",
107+
"data": "\"abc;123\"",
108+
"valid": true
109+
},
110+
{
111+
"description": "Valid - with equals",
112+
"data": "\"abc=123\"",
113+
"valid": true
114+
},
115+
{
116+
"description": "Valid - with question mark",
117+
"data": "\"abc?123\"",
118+
"valid": true
119+
},
120+
{
121+
"description": "Valid - with at sign",
122+
"data": "\"abc@123\"",
123+
"valid": true
124+
},
125+
{
126+
"description": "Valid - with brackets",
127+
"data": "\"[abc]123\"",
128+
"valid": true
129+
},
130+
{
131+
"description": "Valid - with backslash",
132+
"data": "\"abc\\123\"",
133+
"valid": true
134+
},
135+
{
136+
"description": "Valid - with caret",
137+
"data": "\"abc^123\"",
138+
"valid": true
139+
},
140+
{
141+
"description": "Valid - with backtick",
142+
"data": "`abc123`",
143+
"valid": false
144+
},
145+
{
146+
"description": "Valid - with braces",
147+
"data": "\"{abc}123\"",
148+
"valid": true
149+
},
150+
{
151+
"description": "Valid - with pipe",
152+
"data": "\"abc|123\"",
153+
"valid": true
154+
},
155+
{
156+
"description": "Valid - with tilde",
157+
"data": "\"abc~123\"",
158+
"valid": true
159+
},
160+
{
161+
"description": "Valid - uppercase letters",
162+
"data": "\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"",
163+
"valid": true
164+
},
165+
{
166+
"description": "Valid - lowercase letters",
167+
"data": "\"abcdefghijklmnopqrstuvwxyz\"",
168+
"valid": true
169+
},
170+
{
171+
"description": "Valid - all digits",
172+
"data": "\"0123456789\"",
173+
"valid": true
174+
},
175+
{
176+
"description": "Valid - mixed case and symbols",
177+
"data": "\"aBc-123_DeF.456\"",
178+
"valid": true
179+
},
180+
{
181+
"description": "Valid - long value",
182+
"data": "\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"",
183+
"valid": true
184+
},
185+
{
186+
"description": "Invalid - missing opening quote",
187+
"data": "abc123\"",
188+
"valid": false
189+
},
190+
{
191+
"description": "Invalid - missing closing quote",
192+
"data": "\"abc123",
193+
"valid": false
194+
},
195+
{
196+
"description": "Invalid - no quotes",
197+
"data": "abc123",
198+
"valid": false
199+
},
200+
{
201+
"description": "Invalid - single quotes instead of double",
202+
"data": "'abc123'",
203+
"valid": false
204+
},
205+
{
206+
"description": "Invalid - weak ETag prefix (W/)",
207+
"data": "W/\"abc123\"",
208+
"valid": false
209+
},
210+
{
211+
"description": "Invalid - weak ETag prefix lowercase",
212+
"data": "w/\"abc123\"",
213+
"valid": false
214+
},
215+
{
216+
"description": "Invalid - space inside",
217+
"data": "\"abc 123\"",
218+
"valid": false
219+
},
220+
{
221+
"description": "Invalid - tab character",
222+
"data": "\"abc\t123\"",
223+
"valid": false
224+
},
225+
{
226+
"description": "Invalid - newline character",
227+
"data": "\"abc\n123\"",
228+
"valid": false
229+
},
230+
{
231+
"description": "Invalid - carriage return",
232+
"data": "\"abc\r123\"",
233+
"valid": false
234+
},
235+
{
236+
"description": "Invalid - null byte",
237+
"data": "\"abc\u0000123\"",
238+
"valid": false
239+
},
240+
{
241+
"description": "Invalid - control character",
242+
"data": "\"abc\u0001123\"",
243+
"valid": false
244+
},
245+
{
246+
"description": "Invalid - quote character (0x22) inside",
247+
"data": "\"abc\"123\"",
248+
"valid": false
249+
},
250+
{
251+
"description": "Invalid - empty string",
252+
"data": "",
253+
"valid": false
254+
},
255+
{
256+
"description": "Invalid - just quotes with space",
257+
"data": "\" \"",
258+
"valid": false
259+
}
260+
]
261+
}

0 commit comments

Comments
 (0)