proxygen
Main Page
Related Pages
Namespaces
Classes
Files
Examples
File List
File Members
StaticHeaderTable.cpp
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2015-present, Facebook, Inc.
3
* All rights reserved.
4
*
5
* This source code is licensed under the BSD-style license found in the
6
* LICENSE file in the root directory of this source tree. An additional grant
7
* of patent rights can be found in the PATENTS file in the same directory.
8
*
9
*/
10
#include <
proxygen/lib/http/codec/compress/StaticHeaderTable.h
>
11
12
#include <
folly/Indestructible.h
>
13
14
#include <glog/logging.h>
15
#include <list>
16
17
using
std::list
;
18
using
std::string
;
19
using
std::vector;
20
21
namespace
proxygen
{
22
23
// Array of static header table entires pair
24
// Note: if updating this table (should never have to but whatever), update
25
// isHeaderNameInTableWithNonEmptyValue as well
26
const
char
*
s_tableEntries
[][2] = {
27
{
":authority"
,
""
},
28
{
":method"
,
"GET"
},
29
{
":method"
,
"POST"
},
30
{
":path"
,
"/"
},
31
{
":path"
,
"/index.html"
},
32
{
":scheme"
,
"http"
},
33
{
":scheme"
,
"https"
},
34
{
":status"
,
"200"
},
35
{
":status"
,
"204"
},
36
{
":status"
,
"206"
},
37
{
":status"
,
"304"
},
38
{
":status"
,
"400"
},
39
{
":status"
,
"404"
},
40
{
":status"
,
"500"
},
41
{
"accept-charset"
,
""
},
42
{
"accept-encoding"
,
"gzip, deflate"
},
43
{
"accept-language"
,
""
},
44
{
"accept-ranges"
,
""
},
45
{
"accept"
,
""
},
46
{
"access-control-allow-origin"
,
""
},
47
{
"age"
,
""
},
48
{
"allow"
,
""
},
49
{
"authorization"
,
""
},
50
{
"cache-control"
,
""
},
51
{
"content-disposition"
,
""
},
52
{
"content-encoding"
,
""
},
53
{
"content-language"
,
""
},
54
{
"content-length"
,
""
},
55
{
"content-location"
,
""
},
56
{
"content-range"
,
""
},
57
{
"content-type"
,
""
},
58
{
"cookie"
,
""
},
59
{
"date"
,
""
},
60
{
"etag"
,
""
},
61
{
"expect"
,
""
},
62
{
"expires"
,
""
},
63
{
"from"
,
""
},
64
{
"host"
,
""
},
65
{
"if-match"
,
""
},
66
{
"if-modified-since"
,
""
},
67
{
"if-none-match"
,
""
},
68
{
"if-range"
,
""
},
69
{
"if-unmodified-since"
,
""
},
70
{
"last-modified"
,
""
},
71
{
"link"
,
""
},
72
{
"location"
,
""
},
73
{
"max-forwards"
,
""
},
74
{
"proxy-authenticate"
,
""
},
75
{
"proxy-authorization"
,
""
},
76
{
"range"
,
""
},
77
{
"referer"
,
""
},
78
{
"refresh"
,
""
},
79
{
"retry-after"
,
""
},
80
{
"server"
,
""
},
81
{
"set-cookie"
,
""
},
82
{
"strict-transport-security"
,
""
},
83
{
"transfer-encoding"
,
""
},
84
{
"user-agent"
,
""
},
85
{
"vary"
,
""
},
86
{
"via"
,
""
},
87
{
"www-authenticate"
,
""
}
88
};
89
90
const
int
kEntriesSize
=
sizeof
(
s_tableEntries
) / (2 *
sizeof
(
const
char
*));
91
92
bool
StaticHeaderTable::isHeaderCodeInTableWithNonEmptyValue
(
93
HTTPHeaderCode
headerCode) {
94
switch
(headerCode) {
95
case
HTTP_HEADER_COLON_METHOD
:
96
case
HTTP_HEADER_COLON_PATH
:
97
case
HTTP_HEADER_COLON_SCHEME
:
98
case
HTTP_HEADER_COLON_STATUS
:
99
case
HTTP_HEADER_ACCEPT_ENCODING
:
100
return
true
;
101
102
default
:
103
return
false
;
104
}
105
}
106
107
StaticHeaderTable::StaticHeaderTable
(
108
const
char
* entries[][2],
109
int
size
)
110
:
HeaderTable
(0) {
111
// calculate the size
112
list<HPACKHeader> hlist;
113
uint32_t
byteCount = 0;
114
for
(
int
i
= 0;
i
<
size
; ++
i
) {
115
hlist.push_back(
HPACKHeader
(entries[
i
][0], entries[i][1]));
116
byteCount += hlist.back().bytes();
117
}
118
// initialize with a capacity that will exactly fit the static headers
119
init
(byteCount);
120
hlist.reverse();
121
for
(
auto
& header : hlist) {
122
add
(
std::move
(header));
123
}
124
}
125
126
const
StaticHeaderTable
&
StaticHeaderTable::get
() {
127
static
const
folly::Indestructible<StaticHeaderTable>
table(
128
s_tableEntries, kEntriesSize);
129
return
*table;
130
}
131
132
}
proxygen::StaticHeaderTable::StaticHeaderTable
StaticHeaderTable(const char *entries[][2], int size)
Definition:
StaticHeaderTable.cpp:107
i
i
Definition:
gtest_output_test_golden_lin.txt:83
proxygen::HTTP_HEADER_ACCEPT_ENCODING
Definition:
HTTPCommonHeaders.h:40
proxygen::kEntriesSize
const int kEntriesSize
Definition:
StaticHeaderTable.cpp:90
proxygen::HTTP_HEADER_COLON_SCHEME
Definition:
HTTPCommonHeaders.h:127
proxygen::StaticHeaderTable::isHeaderCodeInTableWithNonEmptyValue
static bool isHeaderCodeInTableWithNonEmptyValue(HTTPHeaderCode headerCode)
Definition:
StaticHeaderTable.cpp:92
folly::gen::move
constexpr detail::Map< Move > move
Definition:
Base-inl.h:2567
proxygen::HTTP_HEADER_COLON_METHOD
Definition:
HTTPCommonHeaders.h:124
proxygen::HTTP_HEADER_COLON_PATH
Definition:
HTTPCommonHeaders.h:125
proxygen::HeaderTable
Definition:
HeaderTable.h:26
folly::Indestructible
Definition:
Indestructible.h:61
proxygen::StaticHeaderTable
Definition:
StaticHeaderTable.h:19
proxygen::s_tableEntries
const char * s_tableEntries[][2]
Definition:
StaticHeaderTable.cpp:26
proxygen::HPACKHeader
Definition:
HPACKHeader.h:20
Indestructible.h
proxygen::StaticHeaderTable::get
static const StaticHeaderTable & get()
Definition:
StaticHeaderTable.cpp:126
bm::list
Encoder::MutableCompressedList list
Definition:
BitVectorCodingTest.cpp:78
proxygen::HeaderTable::init
void init(uint32_t capacityVal)
Definition:
HeaderTable.cpp:20
string
const char * string
Definition:
Conv.cpp:212
proxygen
Definition:
ExMessageHandler.h:14
proxygen::HTTPHeaderCode
HTTPHeaderCode
Definition:
HTTPCommonHeaders.h:22
uint32_t
uint32_t
Definition:
ConstexprMathBenchmark.cpp:186
proxygen::HTTP_HEADER_COLON_STATUS
Definition:
HTTPCommonHeaders.h:128
proxygen::HeaderTable::size
uint32_t size() const
Definition:
HeaderTable.h:105
StaticHeaderTable.h
proxygen::HeaderTable::add
virtual bool add(HPACKHeader header)
Definition:
HeaderTable.cpp:33
proxygen
lib
http
codec
compress
StaticHeaderTable.cpp
Generated by
1.8.11