Repository navigation
Expand file tree
/
Copy pathqpack_static_table.hpp
More file actions
150 lines (150 loc) · 6.07 KB
/
Copy pathqpack_static_table.hpp
File metadata and controls
150 lines (150 loc) · 6.07 KB
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
// Appendix data from RFC 7541, Copyright (c) 2015 IETF Trust and the
// persons identified as authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
// 1. Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
#if !defined(HTTPSERVER_COMPILATION)
#error "qpack_static_table.hpp is internal to libhttpserver"
#endif
#ifndef SRC_HTTPSERVER_DETAIL_QPACK_STATIC_TABLE_HPP_
#define SRC_HTTPSERVER_DETAIL_QPACK_STATIC_TABLE_HPP_
#include <array>
#include <cstdint>
#include <optional>
#include <string_view>
namespace httpserver::detail {
struct qpack_static_entry { std::string_view name; std::string_view value; };
// RFC 9204 Appendix A. Zero is a valid static index.
inline constexpr std::array<qpack_static_entry, 99> qpack_static_entries = {{
{":authority", ""},
{":path", "/"},
{"age", "0"},
{"content-disposition", ""},
{"content-length", "0"},
{"cookie", ""},
{"date", ""},
{"etag", ""},
{"if-modified-since", ""},
{"if-none-match", ""},
{"last-modified", ""},
{"link", ""},
{"location", ""},
{"referer", ""},
{"set-cookie", ""},
{":method", "CONNECT"},
{":method", "DELETE"},
{":method", "GET"},
{":method", "HEAD"},
{":method", "OPTIONS"},
{":method", "POST"},
{":method", "PUT"},
{":scheme", "http"},
{":scheme", "https"},
{":status", "103"},
{":status", "200"},
{":status", "304"},
{":status", "404"},
{":status", "503"},
{"accept", "*/*"},
{"accept", "application/dns-message"},
{"accept-encoding", "gzip, deflate, br"},
{"accept-ranges", "bytes"},
{"access-control-allow-headers", "cache-control"},
{"access-control-allow-headers", "content-type"},
{"access-control-allow-origin", "*"},
{"cache-control", "max-age=0"},
{"cache-control", "max-age=2592000"},
{"cache-control", "max-age=604800"},
{"cache-control", "no-cache"},
{"cache-control", "no-store"},
{"cache-control", "public, max-age=31536000"},
{"content-encoding", "br"},
{"content-encoding", "gzip"},
{"content-type", "application/dns-message"},
{"content-type", "application/javascript"},
{"content-type", "application/json"},
{"content-type", "application/x-www-form-urlencoded"},
{"content-type", "image/gif"},
{"content-type", "image/jpeg"},
{"content-type", "image/png"},
{"content-type", "text/css"},
{"content-type", "text/html; charset=utf-8"},
{"content-type", "text/plain"},
{"content-type", "text/plain;charset=utf-8"},
{"range", "bytes=0-"},
{"strict-transport-security", "max-age=31536000"},
{"strict-transport-security", "max-age=31536000; includesubdomains"},
{"strict-transport-security", "max-age=31536000; includesubdomains; preload"},
{"vary", "accept-encoding"},
{"vary", "origin"},
{"x-content-type-options", "nosniff"},
{"x-xss-protection", "1; mode=block"},
{":status", "100"},
{":status", "204"},
{":status", "206"},
{":status", "302"},
{":status", "400"},
{":status", "403"},
{":status", "421"},
{":status", "425"},
{":status", "500"},
{"accept-language", ""},
{"access-control-allow-credentials", "FALSE"},
{"access-control-allow-credentials", "TRUE"},
{"access-control-allow-headers", "*"},
{"access-control-allow-methods", "get"},
{"access-control-allow-methods", "get, post, options"},
{"access-control-allow-methods", "options"},
{"access-control-expose-headers", "content-length"},
{"access-control-request-headers", "content-type"},
{"access-control-request-method", "get"},
{"access-control-request-method", "post"},
{"alt-svc", "clear"},
{"authorization", ""},
{"content-security-policy", "script-src 'none'; object-src 'none'; base-uri 'none'"},
{"early-data", "1"},
{"expect-ct", ""},
{"forwarded", ""},
{"if-range", ""},
{"origin", ""},
{"purpose", "prefetch"},
{"server", ""},
{"timing-allow-origin", "*"},
{"upgrade-insecure-requests", "1"},
{"user-agent", ""},
{"x-forwarded-for", ""},
{"x-frame-options", "deny"},
{"x-frame-options", "sameorigin"},
}};
constexpr const qpack_static_entry* qpack_static_lookup(std::uint64_t index) noexcept {
return index < qpack_static_entries.size() ? &qpack_static_entries[index] : nullptr;
}
constexpr std::optional<std::uint64_t> qpack_static_find_name(std::string_view name) noexcept {
for (std::size_t i = 0; i < qpack_static_entries.size(); ++i) {
if (qpack_static_entries[i].name == name) return i;
}
return std::nullopt;
}
constexpr std::optional<std::uint64_t> qpack_static_find(std::string_view name, std::string_view value) noexcept {
for (std::size_t i = 0; i < qpack_static_entries.size(); ++i) {
if (qpack_static_entries[i].name == name && qpack_static_entries[i].value == value) return i;
}
return std::nullopt;
}
} // namespace httpserver::detail
#endif // SRC_HTTPSERVER_DETAIL_QPACK_STATIC_TABLE_HPP_