13 #include <glog/logging.h> 23 using namespace folly;
33 EXPECT_EQ(headerVec.size() * 2, headers.size());
34 for (
auto&
h: headerVec) {
35 string name = *
h.name;
36 char *mutableName = (
char *)name.data();
49 auto ack = server.encodeTableStateSync();
51 HPACK::DecodeError::NONE);
55 auto ack = server.encodeHeaderAck(streamId);
57 HPACK::DecodeError::NONE);
66 auto encodeResult = client.encode(req, 1);
67 ASSERT_NE(encodeResult.control.get(),
nullptr);
69 HPACK::DecodeError::NONE);
71 auto length = encodeResult.stream->computeChainDataLength();
72 server.decodeStreaming(1,
std::move(encodeResult.stream), length, &cb);
74 auto result = cb.getResult();
76 headersEq(req, result->headers);
81 for (
int i = 0; i < flights; i++) {
82 vector<vector<string>> headers;
83 for (
int j = 0; j < 32; j++) {
84 int value = (i >> 1) * 32 + j;
86 vector<string>({
string(
"foomonkey"), folly::to<string>(
value)}));
89 auto encodeResult = client.encode(req, i + 1);
91 EXPECT_EQ(encodeResult.control.get(),
nullptr);
93 ASSERT_NE(encodeResult.control.get(),
nullptr);
94 CHECK_EQ(server.decodeEncoderStream(
std::move(encodeResult.control)),
95 HPACK::DecodeError::NONE);
98 auto length = encodeResult.stream->computeChainDataLength();
99 server.decodeStreaming(i + 1,
std::move(encodeResult.stream), length, &cb);
101 auto result = cb.getResult();
103 headersEq(req, result->headers);
116 for (
auto i = 0; i < flights * 4; i++) {
117 values.push_back(folly::to<string>(i));
119 client.setEncoderHeaderTableSize(1024);
120 for (
auto f = 0;
f < flights;
f++) {
122 list<unique_ptr<IOBuf>> controlFrames;
123 for (
int i = 0; i < 4; i++) {
125 for (
int j = 0; j < 2; j++) {
129 VLOG(4) <<
"Encoding req=" <<
f * 4 +
i;
130 auto res = client.encode(reqI,
f * 4 + i);
131 if (res.control && res.control->computeChainDataLength() > 0) {
132 controlFrames.emplace_back(
std::move(res.control));
137 std::vector<int> insertOrder{0, 3, 2, 1};
138 if (!controlFrames.empty()) {
139 auto control =
std::move(controlFrames.front());
140 controlFrames.pop_front();
141 server.decodeEncoderStream(
std::move(control));
143 for (
auto i: insertOrder) {
144 auto& encodedReq = data[
i].first;
145 auto len = encodedReq->computeChainDataLength();
146 server.decodeStreaming(i,
std::move(encodedReq), len, &data[i].second);
148 while (!controlFrames.empty()) {
149 auto control =
std::move(controlFrames.front());
150 controlFrames.pop_front();
151 server.decodeEncoderStream(
std::move(control));
154 for (
auto& d: data) {
155 auto result = d.second.getResult();
158 for (
int j = 0; j < 2; j++) {
162 headersEq(reqI, result->headers);
163 headerAck(
f * 4 + i);
166 VLOG(4) <<
"getHolBlockCount=" << server.getHolBlockCount();
169 EXPECT_EQ(server.getHolBlockCount(), 30);
174 vector<vector<string>> headers = {
175 {
"Content-Length",
"80"},
176 {
"Content-Encoding",
"gzip"},
177 {
"X-FB-Debug",
"eirtijvdgtccffkutnbttcgbfieghgev"}
183 server.setStats(&stats);
184 auto encResult = server.encode(resp, 1);
192 server.setStats(
nullptr);
196 client.setStats(&stats);
198 auto len = encResult.stream->computeChainDataLength();
199 client.decodeEncoderStream(
std::move(encResult.control));
200 client.decodeStreaming(1,
std::move(encResult.stream), len, &cb);
203 auto& decoded = result->headers;
204 CHECK_EQ(decoded.size(), 3 * 2);
211 client.setStats(
nullptr);
void headerAck(uint64_t streamId)
vector< compress::Header > basicHeaders()
#define EXPECT_EQ(val1, val2)
constexpr detail::Map< Move > move
vector< compress::Header > headersFromArray(vector< vector< string >> &a)
—— Concurrent Priority Queue Implementation ——
std::deque< HeaderPiece > HeaderPieceList
constexpr auto data(C &c) -> decltype(c.data())
TEST_F(AsyncSSLSocketWriteTest, write_coalescing1)
#define EXPECT_TRUE(condition)
void toLowerAscii(char *str, size_t length)
uint64_t value(const typename LockFreeRingBuffer< T, Atom >::Cursor &rbcursor)
#define ASSERT_NE(val1, val2)
std::vector< int > values(1'000)
folly::Expected< HeaderDecodeResult, HPACK::DecodeError > getResult()
#define EXPECT_GT(val1, val2)