quiche/h3/qpack/
static_table.rs

1// Copyright (C) 2020, Cloudflare, Inc.
2// All rights reserved.
3//
4// Redistribution and use in source and binary forms, with or without
5// modification, are permitted provided that the following conditions are
6// met:
7//
8//     * Redistributions of source code must retain the above copyright notice,
9//       this list of conditions and the following disclaimer.
10//
11//     * Redistributions in binary form must reproduce the above copyright
12//       notice, this list of conditions and the following disclaimer in the
13//       documentation and/or other materials provided with the distribution.
14//
15// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
16// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
17// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
19// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
23// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
24// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
27/// This table maps the statically encoded QPACK entries to their
28/// index. The mapping is from name length to a list of names of this
29/// length, with the list of possible values for that name and the proper
30/// encoding for this name: value pair.
31type HeaderName = &'static [u8];
32type HeaderValue = &'static [u8];
33type HeaderValueEncPairs = &'static [(HeaderValue, u64)];
34pub const STATIC_ENCODE_TABLE: &[&[(HeaderName, HeaderValueEncPairs)]] = &[
35    // Headers of len 0
36    &[],
37    // Headers of len 1
38    &[],
39    // Headers of len 2
40    &[],
41    // Headers of len 3
42    &[(b"age", &[(b"0", 2)])],
43    // Headers of len 4
44    &[
45        (b"etag", &[(b"", 7)]),
46        (b"date", &[(b"", 6)]),
47        (b"link", &[(b"", 11)]),
48        (b"vary", &[(b"accept-encoding", 59), (b"origin", 60)]),
49    ],
50    // Headers of len 5
51    &[(b"range", &[(b"bytes=0-", 55)]), (b":path", &[(b"/", 1)])],
52    // Headers of len 6
53    &[
54        (b"cookie", &[(b"", 5)]),
55        (b"origin", &[(b"", 90)]),
56        (b"server", &[(b"", 92)]),
57        (b"accept", &[(b"*/*", 29), (b"application/dns-message", 30)]),
58    ],
59    // Headers of len 7
60    &[
61        (b"purpose", &[(b"prefetch", 91)]),
62        (b"referer", &[(b"", 13)]),
63        (b"alt-svc", &[(b"clear", 83)]),
64        (b":status", &[
65            (b"103", 24),
66            (b"200", 25),
67            (b"304", 26),
68            (b"404", 27),
69            (b"503", 28),
70            (b"100", 63),
71            (b"204", 64),
72            (b"206", 65),
73            (b"302", 66),
74            (b"400", 67),
75            (b"403", 68),
76            (b"421", 69),
77            (b"425", 70),
78            (b"500", 71),
79        ]),
80        (b":scheme", &[(b"http", 22), (b"https", 23)]),
81        (b":method", &[
82            (b"CONNECT", 15),
83            (b"DELETE", 16),
84            (b"GET", 17),
85            (b"HEAD", 18),
86            (b"OPTIONS", 19),
87            (b"POST", 20),
88            (b"PUT", 21),
89        ]),
90    ],
91    // Headers of len 8
92    &[(b"location", &[(b"", 12)]), (b"if-range", &[(b"", 89)])],
93    // Headers of len 9
94    &[(b"expect-ct", &[(b"", 87)]), (b"forwarded", &[(b"", 88)])],
95    // Headers of len 10
96    &[
97        (b"user-agent", &[(b"", 95)]),
98        (b":authority", &[(b"", 0)]),
99        (b"set-cookie", &[(b"", 14)]),
100        (b"early-data", &[(b"1", 86)]),
101    ],
102    // Headers of len 11
103    &[],
104    // Headers of len 12
105    &[(b"content-type", &[
106        (b"application/dns-message", 44),
107        (b"application/javascript", 45),
108        (b"application/json", 46),
109        (b"application/x-www-form-urlencoded", 47),
110        (b"image/gif", 48),
111        (b"image/jpeg", 49),
112        (b"image/png", 50),
113        (b"text/css", 51),
114        (b"text/html; charset=utf-8", 52),
115        (b"text/plain", 53),
116        (b"text/plain;charset=utf-8", 54),
117    ])],
118    // Headers of len 13
119    &[
120        (b"last-modified", &[(b"", 10)]),
121        (b"accept-ranges", &[(b"bytes", 32)]),
122        (b"authorization", &[(b"", 84)]),
123        (b"if-none-match", &[(b"", 9)]),
124        (b"cache-control", &[
125            (b"max-age=0", 36),
126            (b"max-age=2592000", 37),
127            (b"max-age=604800", 38),
128            (b"no-cache", 39),
129            (b"no-store", 40),
130            (b"public, max-age=31536000", 41),
131        ]),
132    ],
133    // Headers of len 14
134    &[(b"content-length", &[(b"0", 4)])],
135    // Headers of len 15
136    &[
137        (b"accept-encoding", &[(b"gzip, deflate, br", 31)]),
138        (b"x-forwarded-for", &[(b"", 96)]),
139        (b"accept-language", &[(b"", 72)]),
140        (b"x-frame-options", &[(b"deny", 97), (b"sameorigin", 98)]),
141    ],
142    // Headers of len 16
143    &[
144        (b"content-encoding", &[(b"br", 42), (b"gzip", 43)]),
145        (b"x-xss-protection", &[(b"1; mode=block", 62)]),
146    ],
147    // Headers of len 17
148    &[(b"if-modified-since", &[(b"", 8)])],
149    // Headers of len 18
150    &[],
151    // Headers of len 19
152    &[
153        (b"content-disposition", &[(b"", 3)]),
154        (b"timing-allow-origin", &[(b"*", 93)]),
155    ],
156    // Headers of len 20
157    &[],
158    // Headers of len 21
159    &[],
160    // Headers of len 22
161    &[(b"x-content-type-options", &[(b"nosniff", 61)])],
162    // Headers of len 23
163    &[(b"content-security-policy", &[(
164        b"script-src 'none'; object-src 'none'; base-uri 'none'",
165        85,
166    )])],
167    // Headers of len 24
168    &[],
169    // Headers of len 25
170    &[
171        (b"upgrade-insecure-requests", &[(b"1", 94)]),
172        (b"strict-transport-security", &[
173            (b"max-age=31536000", 56),
174            (b"max-age=31536000; includesubdomains", 57),
175            (b"max-age=31536000; includesubdomains; preload", 58),
176        ]),
177    ],
178    // Headers of len 26
179    &[],
180    // Headers of len 27
181    &[(b"access-control-allow-origin", &[(b"*", 35)])],
182    // Headers of len 28
183    &[
184        (b"access-control-allow-methods", &[
185            (b"get", 76),
186            (b"get, post, options", 77),
187            (b"options", 78),
188        ]),
189        (b"access-control-allow-headers", &[
190            (b"cache-control", 33),
191            (b"content-type", 34),
192            (b"*", 75),
193        ]),
194    ],
195    // Headers of len 29
196    &[
197        (b"access-control-expose-headers", &[(b"content-length", 79)]),
198        (b"access-control-request-method", &[
199            (b"get", 81),
200            (b"post", 82),
201        ]),
202    ],
203    // Headers of len 30
204    &[(b"access-control-request-headers", &[(b"content-type", 80)])],
205    // Headers of len 31
206    &[],
207    // Headers of len 32
208    &[(b"access-control-allow-credentials", &[
209        (b"FALSE", 73),
210        (b"TRUE", 74),
211    ])],
212];
213
214pub const STATIC_DECODE_TABLE: [(&[u8], &[u8]); 99] = [
215    (b":authority", b""),
216    (b":path", b"/"),
217    (b"age", b"0"),
218    (b"content-disposition", b""),
219    (b"content-length", b"0"),
220    (b"cookie", b""),
221    (b"date", b""),
222    (b"etag", b""),
223    (b"if-modified-since", b""),
224    (b"if-none-match", b""),
225    (b"last-modified", b""),
226    (b"link", b""),
227    (b"location", b""),
228    (b"referer", b""),
229    (b"set-cookie", b""),
230    (b":method", b"CONNECT"),
231    (b":method", b"DELETE"),
232    (b":method", b"GET"),
233    (b":method", b"HEAD"),
234    (b":method", b"OPTIONS"),
235    (b":method", b"POST"),
236    (b":method", b"PUT"),
237    (b":scheme", b"http"),
238    (b":scheme", b"https"),
239    (b":status", b"103"),
240    (b":status", b"200"),
241    (b":status", b"304"),
242    (b":status", b"404"),
243    (b":status", b"503"),
244    (b"accept", b"*/*"),
245    (b"accept", b"application/dns-message"),
246    (b"accept-encoding", b"gzip, deflate, br"),
247    (b"accept-ranges", b"bytes"),
248    (b"access-control-allow-headers", b"cache-control"),
249    (b"access-control-allow-headers", b"content-type"),
250    (b"access-control-allow-origin", b"*"),
251    (b"cache-control", b"max-age=0"),
252    (b"cache-control", b"max-age=2592000"),
253    (b"cache-control", b"max-age=604800"),
254    (b"cache-control", b"no-cache"),
255    (b"cache-control", b"no-store"),
256    (b"cache-control", b"public, max-age=31536000"),
257    (b"content-encoding", b"br"),
258    (b"content-encoding", b"gzip"),
259    (b"content-type", b"application/dns-message"),
260    (b"content-type", b"application/javascript"),
261    (b"content-type", b"application/json"),
262    (b"content-type", b"application/x-www-form-urlencoded"),
263    (b"content-type", b"image/gif"),
264    (b"content-type", b"image/jpeg"),
265    (b"content-type", b"image/png"),
266    (b"content-type", b"text/css"),
267    (b"content-type", b"text/html; charset=utf-8"),
268    (b"content-type", b"text/plain"),
269    (b"content-type", b"text/plain;charset=utf-8"),
270    (b"range", b"bytes=0-"),
271    (b"strict-transport-security", b"max-age=31536000"),
272    (
273        b"strict-transport-security",
274        b"max-age=31536000; includesubdomains",
275    ),
276    (
277        b"strict-transport-security",
278        b"max-age=31536000; includesubdomains; preload",
279    ),
280    (b"vary", b"accept-encoding"),
281    (b"vary", b"origin"),
282    (b"x-content-type-options", b"nosniff"),
283    (b"x-xss-protection", b"1; mode=block"),
284    (b":status", b"100"),
285    (b":status", b"204"),
286    (b":status", b"206"),
287    (b":status", b"302"),
288    (b":status", b"400"),
289    (b":status", b"403"),
290    (b":status", b"421"),
291    (b":status", b"425"),
292    (b":status", b"500"),
293    (b"accept-language", b""),
294    (b"access-control-allow-credentials", b"FALSE"),
295    (b"access-control-allow-credentials", b"TRUE"),
296    (b"access-control-allow-headers", b"*"),
297    (b"access-control-allow-methods", b"get"),
298    (b"access-control-allow-methods", b"get, post, options"),
299    (b"access-control-allow-methods", b"options"),
300    (b"access-control-expose-headers", b"content-length"),
301    (b"access-control-request-headers", b"content-type"),
302    (b"access-control-request-method", b"get"),
303    (b"access-control-request-method", b"post"),
304    (b"alt-svc", b"clear"),
305    (b"authorization", b""),
306    (
307        b"content-security-policy",
308        b"script-src 'none'; object-src 'none'; base-uri 'none'",
309    ),
310    (b"early-data", b"1"),
311    (b"expect-ct", b""),
312    (b"forwarded", b""),
313    (b"if-range", b""),
314    (b"origin", b""),
315    (b"purpose", b"prefetch"),
316    (b"server", b""),
317    (b"timing-allow-origin", b"*"),
318    (b"upgrade-insecure-requests", b"1"),
319    (b"user-agent", b""),
320    (b"x-forwarded-for", b""),
321    (b"x-frame-options", b"deny"),
322    (b"x-frame-options", b"sameorigin"),
323];