blob: f1986f798ad2908229d7d36f50c44157db21a84c [file] [log] [blame]
QUICHE teama6ef0a62019-03-07 20:34:33 -05001// Copyright (c) 2018 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "net/third_party/quiche/src/quic/core/qpack/qpack_static_table.h"
6
7#include "net/third_party/quiche/src/quic/platform/api/quic_arraysize.h"
8#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h"
9#include "net/third_party/quiche/src/quic/platform/api/quic_ptr_util.h"
10
11namespace quic {
12
13// The "constructor" for a QpackStaticEntry that computes the lengths at
14// compile time.
15#define STATIC_ENTRY(name, value) \
16 { name, QUIC_ARRAYSIZE(name) - 1, value, QUIC_ARRAYSIZE(value) - 1 }
17
18const std::vector<QpackStaticEntry>& QpackStaticTableVector() {
19 static const auto* kQpackStaticTable = new std::vector<QpackStaticEntry>{
20 STATIC_ENTRY(":authority", ""), // 0
21 STATIC_ENTRY(":path", "/"), // 1
22 STATIC_ENTRY("age", "0"), // 2
23 STATIC_ENTRY("content-disposition", ""), // 3
24 STATIC_ENTRY("content-length", "0"), // 4
25 STATIC_ENTRY("cookie", ""), // 5
26 STATIC_ENTRY("date", ""), // 6
27 STATIC_ENTRY("etag", ""), // 7
28 STATIC_ENTRY("if-modified-since", ""), // 8
29 STATIC_ENTRY("if-none-match", ""), // 9
30 STATIC_ENTRY("last-modified", ""), // 10
31 STATIC_ENTRY("link", ""), // 11
32 STATIC_ENTRY("location", ""), // 12
33 STATIC_ENTRY("referer", ""), // 13
34 STATIC_ENTRY("set-cookie", ""), // 14
35 STATIC_ENTRY(":method", "CONNECT"), // 15
36 STATIC_ENTRY(":method", "DELETE"), // 16
37 STATIC_ENTRY(":method", "GET"), // 17
38 STATIC_ENTRY(":method", "HEAD"), // 18
39 STATIC_ENTRY(":method", "OPTIONS"), // 19
40 STATIC_ENTRY(":method", "POST"), // 20
41 STATIC_ENTRY(":method", "PUT"), // 21
42 STATIC_ENTRY(":scheme", "http"), // 22
43 STATIC_ENTRY(":scheme", "https"), // 23
44 STATIC_ENTRY(":status", "103"), // 24
45 STATIC_ENTRY(":status", "200"), // 25
46 STATIC_ENTRY(":status", "304"), // 26
47 STATIC_ENTRY(":status", "404"), // 27
48 STATIC_ENTRY(":status", "503"), // 28
49 STATIC_ENTRY("accept", "*/*"), // 29
50 STATIC_ENTRY("accept", "application/dns-message"), // 30
51 STATIC_ENTRY("accept-encoding", "gzip, deflate, br"), // 31
52 STATIC_ENTRY("accept-ranges", "bytes"), // 32
53 STATIC_ENTRY("access-control-allow-headers", "cache-control"), // 33
54 STATIC_ENTRY("access-control-allow-headers", "content-type"), // 35
55 STATIC_ENTRY("access-control-allow-origin", "*"), // 35
56 STATIC_ENTRY("cache-control", "max-age=0"), // 36
57 STATIC_ENTRY("cache-control", "max-age=2592000"), // 37
58 STATIC_ENTRY("cache-control", "max-age=604800"), // 38
59 STATIC_ENTRY("cache-control", "no-cache"), // 39
60 STATIC_ENTRY("cache-control", "no-store"), // 40
61 STATIC_ENTRY("cache-control", "public, max-age=31536000"), // 41
62 STATIC_ENTRY("content-encoding", "br"), // 42
63 STATIC_ENTRY("content-encoding", "gzip"), // 43
64 STATIC_ENTRY("content-type", "application/dns-message"), // 44
65 STATIC_ENTRY("content-type", "application/javascript"), // 45
66 STATIC_ENTRY("content-type", "application/json"), // 46
67 STATIC_ENTRY("content-type", "application/x-www-form-urlencoded"), // 47
68 STATIC_ENTRY("content-type", "image/gif"), // 48
69 STATIC_ENTRY("content-type", "image/jpeg"), // 49
70 STATIC_ENTRY("content-type", "image/png"), // 50
71 STATIC_ENTRY("content-type", "text/css"), // 51
72 STATIC_ENTRY("content-type", "text/html; charset=utf-8"), // 52
73 STATIC_ENTRY("content-type", "text/plain"), // 53
74 STATIC_ENTRY("content-type", "text/plain;charset=utf-8"), // 54
75 STATIC_ENTRY("range", "bytes=0-"), // 55
76 STATIC_ENTRY("strict-transport-security", "max-age=31536000"), // 56
77 STATIC_ENTRY("strict-transport-security",
78 "max-age=31536000; includesubdomains"), // 57
79 STATIC_ENTRY("strict-transport-security",
80 "max-age=31536000; includesubdomains; preload"), // 58
81 STATIC_ENTRY("vary", "accept-encoding"), // 59
82 STATIC_ENTRY("vary", "origin"), // 60
83 STATIC_ENTRY("x-content-type-options", "nosniff"), // 61
84 STATIC_ENTRY("x-xss-protection", "1; mode=block"), // 62
85 STATIC_ENTRY(":status", "100"), // 63
86 STATIC_ENTRY(":status", "204"), // 64
87 STATIC_ENTRY(":status", "206"), // 65
88 STATIC_ENTRY(":status", "302"), // 66
89 STATIC_ENTRY(":status", "400"), // 67
90 STATIC_ENTRY(":status", "403"), // 68
91 STATIC_ENTRY(":status", "421"), // 69
92 STATIC_ENTRY(":status", "425"), // 70
93 STATIC_ENTRY(":status", "500"), // 71
94 STATIC_ENTRY("accept-language", ""), // 72
95 STATIC_ENTRY("access-control-allow-credentials", "FALSE"), // 73
96 STATIC_ENTRY("access-control-allow-credentials", "TRUE"), // 74
97 STATIC_ENTRY("access-control-allow-headers", "*"), // 75
98 STATIC_ENTRY("access-control-allow-methods", "get"), // 76
99 STATIC_ENTRY("access-control-allow-methods", "get, post, options"), // 77
100 STATIC_ENTRY("access-control-allow-methods", "options"), // 78
101 STATIC_ENTRY("access-control-expose-headers", "content-length"), // 79
102 STATIC_ENTRY("access-control-request-headers", "content-type"), // 80
103 STATIC_ENTRY("access-control-request-method", "get"), // 81
104 STATIC_ENTRY("access-control-request-method", "post"), // 82
105 STATIC_ENTRY("alt-svc", "clear"), // 83
106 STATIC_ENTRY("authorization", ""), // 84
107 STATIC_ENTRY(
108 "content-security-policy",
109 "script-src 'none'; object-src 'none'; base-uri 'none'"), // 85
110 STATIC_ENTRY("early-data", "1"), // 86
111 STATIC_ENTRY("expect-ct", ""), // 87
112 STATIC_ENTRY("forwarded", ""), // 88
113 STATIC_ENTRY("if-range", ""), // 89
114 STATIC_ENTRY("origin", ""), // 90
115 STATIC_ENTRY("purpose", "prefetch"), // 91
116 STATIC_ENTRY("server", ""), // 92
117 STATIC_ENTRY("timing-allow-origin", "*"), // 93
118 STATIC_ENTRY("upgrade-insecure-requests", "1"), // 94
119 STATIC_ENTRY("user-agent", ""), // 95
120 STATIC_ENTRY("x-forwarded-for", ""), // 96
121 STATIC_ENTRY("x-frame-options", "deny"), // 97
122 STATIC_ENTRY("x-frame-options", "sameorigin"), // 98
123 };
124 return *kQpackStaticTable;
125}
126
127#undef STATIC_ENTRY
128
129const QpackStaticTable& ObtainQpackStaticTable() {
130 static const QpackStaticTable* const shared_static_table = []() {
131 auto* table = new QpackStaticTable();
132 table->Initialize(QpackStaticTableVector().data(),
133 QpackStaticTableVector().size());
134 CHECK(table->IsInitialized());
135 return table;
136 }();
137 return *shared_static_table;
138}
139
140} // namespace quic