proxygen
|
#include <HPACKEncodeBuffer.h>
Public Member Functions | |
HPACKEncodeBuffer (uint32_t growthSize, bool huffmanEnabled) | |
HPACKEncodeBuffer (uint32_t growthSize) | |
~HPACKEncodeBuffer () | |
std::unique_ptr< folly::IOBuf > | release () |
void | clear () |
void | addHeadroom (uint32_t bytes) |
uint32_t | encodeInteger (uint64_t value, uint8_t instruction, uint8_t nbit) |
uint32_t | encodeInteger (uint64_t value, const HPACK::Instruction &instruction) |
uint32_t | encodeInteger (uint64_t value) |
uint32_t | encodeLiteral (folly::StringPiece literal) |
uint32_t | encodeLiteral (uint8_t instruction, uint8_t nbit, folly::StringPiece literal) |
uint32_t | encodeHuffman (folly::StringPiece literal) |
uint32_t | encodeHuffman (uint8_t instruction, uint8_t nbit, folly::StringPiece literal) |
std::string | toBin () |
Private Member Functions | |
void | append (uint8_t byte) |
Private Attributes | |
folly::IOBufQueue | bufQueue_ |
folly::io::QueueAppender | buf_ |
uint32_t | growthSize_ |
bool | huffmanEnabled_ |
Definition at line 20 of file HPACKEncodeBuffer.h.
proxygen::HPACKEncodeBuffer::HPACKEncodeBuffer | ( | uint32_t | growthSize, |
bool | huffmanEnabled | ||
) |
Definition at line 24 of file HPACKEncodeBuffer.cpp.
|
explicit |
Definition at line 32 of file HPACKEncodeBuffer.cpp.
|
inline |
Definition at line 29 of file HPACKEncodeBuffer.h.
void proxygen::HPACKEncodeBuffer::addHeadroom | ( | uint32_t | bytes | ) |
Add headroom at the beginning of the IOBufQueue Meant to be called before encoding anything.
Definition at line 38 of file HPACKEncodeBuffer.cpp.
References folly::IOBufQueue::append(), bufQueue_, folly::IOBufQueue::front(), growthSize_, max, and folly::gen::move.
Referenced by clear(), proxygen::HPACKEncoder::encode(), and proxygen::QPACKEncoder::encode().
|
private |
append one byte at the end of buffer ensuring we always have enough space
Definition at line 47 of file HPACKEncodeBuffer.cpp.
References buf_, and folly::io::detail::Writable< Derived >::push().
Referenced by clear(), and encodeInteger().
|
inline |
Definition at line 38 of file HPACKEncodeBuffer.h.
References addHeadroom(), append(), bufQueue_, folly::IOBufQueue::clear(), encodeHuffman(), encodeInteger(), encodeLiteral(), string, toBin(), uint32_t, uint64_t, uint8_t, and value.
uint32_t proxygen::HPACKEncodeBuffer::encodeHuffman | ( | folly::StringPiece | literal | ) |
encodes a string using huffman encoding
Definition at line 95 of file HPACKEncodeBuffer.cpp.
Referenced by clear(), and encodeLiteral().
uint32_t proxygen::HPACKEncodeBuffer::encodeHuffman | ( | uint8_t | instruction, |
uint8_t | nbit, | ||
folly::StringPiece | literal | ||
) |
encodes a string using huffman encoding QPACK style, where literal length has an nbit prefix.
Definition at line 109 of file HPACKEncodeBuffer.cpp.
References buf_, count, encodeInteger(), proxygen::huffman::huffTree(), folly::size(), uint32_t, and uint8_t.
uint32_t proxygen::HPACKEncodeBuffer::encodeInteger | ( | uint64_t | value, |
uint8_t | instruction, | ||
uint8_t | nbit | ||
) |
Encode the integer value using variable-length layout and the given instruction using an nbit prefix. Per the spec, prefix is the portion of value that fits in one byte. The instruction is given as 1-byte value (not need for shifting) used only for the first byte. It starts from MSB.
For example for integer=3, instruction=0x80, nbit=6:
MSB LSB X X 0 0 0 0 1 1 (value) 1 0 X X X X X X (instruction) 1 0 0 0 0 0 1 1 (encoded value)
Definition at line 61 of file HPACKEncodeBuffer.cpp.
References append(), count, proxygen::HPACK::NBIT_MASKS, uint32_t, uint8_t, and value.
Referenced by clear(), proxygen::HPACKEncoder::encodeAsIndex(), proxygen::QPACKDecoder::encodeCancelStream(), proxygen::QPACKEncoder::encodeDuplicate(), proxygen::QPACKDecoder::encodeHeaderAck(), proxygen::QPACKEncoder::encodeHeaderQ(), encodeHuffman(), encodeInteger(), proxygen::HPACKEncoder::encodeLiteral(), encodeLiteral(), proxygen::QPACKEncoder::encodeLiteralQHelper(), proxygen::QPACKEncoder::encodeQ(), proxygen::QPACKDecoder::encodeTableStateSync(), proxygen::HPACKEncoderBase::handlePendingContextUpdate(), and TEST_F().
uint32_t proxygen::HPACKEncodeBuffer::encodeInteger | ( | uint64_t | value, |
const HPACK::Instruction & | instruction | ||
) |
Definition at line 55 of file HPACKEncodeBuffer.cpp.
References proxygen::HPACK::Instruction::code, encodeInteger(), and proxygen::HPACK::Instruction::prefixLength.
Definition at line 51 of file HPACKEncodeBuffer.cpp.
References encodeInteger().
uint32_t proxygen::HPACKEncodeBuffer::encodeLiteral | ( | folly::StringPiece | literal | ) |
encodes a string, either header name or header value
Definition at line 123 of file HPACKEncodeBuffer.cpp.
Referenced by clear(), proxygen::HPACKEncoder::encodeLiteral(), proxygen::QPACKEncoder::encodeLiteralQHelper(), and TEST_F().
uint32_t proxygen::HPACKEncodeBuffer::encodeLiteral | ( | uint8_t | instruction, |
uint8_t | nbit, | ||
folly::StringPiece | literal | ||
) |
encodes a string, either header name or header value QPACK style, where literal length has an nbit prefix.
Definition at line 127 of file HPACKEncodeBuffer.cpp.
References buf_, count, folly::Range< Iter >::data(), encodeHuffman(), encodeInteger(), huffmanEnabled_, folly::io::detail::Writable< Derived >::push(), folly::Range< Iter >::size(), uint32_t, and uint8_t.
|
inline |
transfer ownership of the underlying IOBuf's
Definition at line 34 of file HPACKEncodeBuffer.h.
References bufQueue_, and folly::IOBufQueue::move().
Referenced by proxygen::HPACKEncoder::encode(), proxygen::QPACKDecoder::encodeCancelStream(), proxygen::QPACKDecoder::encodeHeaderAck(), proxygen::QPACKEncoder::encodeQ(), proxygen::QPACKDecoder::encodeTableStateSync(), HPACKBufferTests::releaseData(), and TEST_F().
string proxygen::HPACKEncodeBuffer::toBin | ( | ) |
prints the content of an IOBuf in binary format. Useful for debugging.
Definition at line 141 of file HPACKEncodeBuffer.cpp.
References bufQueue_, folly::IOBufQueue::front(), and proxygen::IOBufPrinter::printBin().
Referenced by clear(), and TEST_F().
|
private |
Definition at line 111 of file HPACKEncodeBuffer.h.
Referenced by append(), encodeHuffman(), and encodeLiteral().
|
private |
Definition at line 110 of file HPACKEncodeBuffer.h.
Referenced by addHeadroom(), clear(), release(), and toBin().
|
private |
Definition at line 112 of file HPACKEncodeBuffer.h.
Referenced by addHeadroom().
|
private |
Definition at line 113 of file HPACKEncodeBuffer.h.
Referenced by encodeLiteral().