14 #include <glog/logging.h> 22 using std::unique_ptr;
28 ofstream outfile(filename, ofstream::binary);
32 outfile.write((
const char *)p->
data(), p->
length());
34 }
while (p->
next() != buf);
40 vector<HPACKHeader>& decodedHeaders) {
41 EXPECT_EQ(headers.size(), decodedHeaders.size());
42 std::sort(decodedHeaders.begin(), decodedHeaders.end());
43 std::sort(headers.begin(), headers.end());
44 if (headers.size() != decodedHeaders.size()) {
45 std::cerr <<
printDelta(decodedHeaders, headers);
46 CHECK(
false) <<
"Mismatched headers size";
49 if (headers != decodedHeaders) {
50 std::cerr <<
printDelta(headers, decodedHeaders);
51 CHECK(
false) <<
"Mismatched headers";
56 vector<HPACKHeader>& headers,
59 unique_ptr<IOBuf> encoded = encoder.
encode(headers);
73 vector<HPACKHeader>& headers,
76 auto encoded = encoder.
encode(headers, 0, 1);
78 if (encoded.control) {
82 CHECK(encoded.stream);
83 auto length = encoded.stream->computeChainDataLength();
97 auto headers = std::make_unique<HPACKDecoder::headers_t>();
99 uint32_t totalBytes = buffer ? cursor.totalLength() : 0;
109 vector<compress::Header> headers;
117 static vector<vector<string>> headersStrings = {
118 {
":path",
"/index.php"},
119 {
":authority",
"www.facebook.com"},
121 {
":scheme",
"https"},
122 {
"Host",
"www.facebook.com"},
123 {
"accept-encoding",
"gzip"}
unique_ptr< IOBuf > encodeDecode(vector< HPACKHeader > &headers, HPACKEncoder &encoder, HPACKDecoder &decoder)
std::vector< uint8_t > buffer(kBufferSize+16)
std::unique_ptr< folly::IOBuf > encodeTableStateSync()
HPACK::DecodeError decodeEncoderStream(std::unique_ptr< folly::IOBuf > buf)
void verifyHeaders(vector< HPACKHeader > &headers, vector< HPACKHeader > &decodedHeaders)
vector< compress::Header > basicHeaders()
const QPACKHeaderTable & getTable() const
std::unique_ptr< std::vector< HPACKHeader > > hpackHeaders() const
#define EXPECT_EQ(val1, val2)
constexpr detail::Map< Move > move
vector< compress::Header > headersFromArray(vector< vector< string >> &a)
const uint8_t * data() const
HPACK::DecodeError decodeDecoderStream(std::unique_ptr< folly::IOBuf > buf)
string printDelta(const vector< HPACKHeader > &v1, const vector< HPACKHeader > &v2)
EncodeResult encode(const std::vector< HPACKHeader > &headers, uint32_t headroom, uint64_t streamId)
unique_ptr< HPACKDecoder::headers_t > decode(HPACKDecoder &decoder, const IOBuf *buffer)
void decodeStreaming(uint64_t streamId, std::unique_ptr< folly::IOBuf > block, uint32_t totalBytes, HPACK::StreamingCallback *streamingCb)
std::size_t length() const
void decodeStreaming(folly::io::Cursor &cursor, uint32_t totalBytes, HPACK::StreamingCallback *streamingCb)
const HeaderTable & getTable() const
std::unique_ptr< folly::IOBuf > encode(const std::vector< HPACKHeader > &headers, uint32_t headroom=0)
void dumpToFile(const string &filename, const IOBuf *buf)
std::unique_ptr< folly::IOBuf > encodeHeaderAck(uint64_t streamId) const