21 controlBuffer_(kBufferGrowth, huffman) {
34 return encodeQ(headers, streamId);
40 outstandingBlocks.emplace_back();
45 for (
const auto& header: headers) {
53 if (largestReference > baseIndex) {
63 streamBuffer->prependChain(
std::move(streamBlock));
97 bool duplicated =
false;
100 indexable &= (duplicated && index == 0);
106 bool isStaticName =
false;
107 std::tie(isStaticName, nameIndex, absoluteNameIndex) =
122 absoluteNameIndex = 0;
131 baseIndex, largestReference);
139 if (index > baseIndex) {
155 VLOG(4) <<
"Encoded duplicate index=" << relativeIndex;
165 bool isStatic =
true;
166 if (nameIndex == 0) {
169 if (nameIndex != 0) {
171 if (absoluteNameIndex) {
176 absoluteNameIndex = 0;
180 return std::tuple<bool, uint32_t, uint32_t>(
181 isStatic, nameIndex, absoluteNameIndex);
187 if (absoluteNameIndex > 0) {
192 if (absoluteNameIndex > baseIndex) {
196 absoluteNameIndex - baseIndex,
202 isStaticName ? nameIndex : baseIndex - absoluteNameIndex + 1,
209 CHECK_NE(absoluteIndex, 0);
211 if (absoluteIndex > *largestReference) {
212 *largestReference = absoluteIndex;
219 VLOG(5) <<
"Bumping refcount for absoluteIndex=" << absoluteIndex;
243 DCHECK(!isStaticName || !postBase);
259 VLOG(10) <<
"encoding name index=" << nameIndex;
265 DCHECK_GE(nameIndex, 1);
278 std::unique_ptr<folly::IOBuf> buf) {
285 consumed = dbuf.consumedBytes();
286 auto byte = dbuf.peek();
297 LOG(
ERROR) <<
"Failed to decode num inserts, err=" << err;
318 LOG(
ERROR) <<
"Failed to decode streamId, err=" << err;
334 LOG(
ERROR) <<
"Received an ack with no outstanding header blocks stream=" 343 VLOG(5) << ((
all) ?
"onCancelStream" :
"onHeaderAck") <<
" streamId=" 347 for (
auto& block: it->second) {
348 for (
auto i: block.references) {
351 if (block.vulnerable) {
357 auto block =
std::move(it->second.front());
358 it->second.pop_front();
360 for (
auto i: block.references) {
361 VLOG(5) <<
"Decrementing refcount for absoluteIndex=" <<
i;
364 if (block.vulnerable) {
368 if (!block.references.empty()) {
369 auto largestReference = *block.references.rbegin();
370 VLOG(5) <<
"Implicitly acknowledging absoluteIndex=" << largestReference;
374 if (it->second.empty()) {
const Instruction Q_TABLE_STATE_SYNC
std::vector< uint8_t > buffer(kBufferSize+16)
const Instruction Q_INSERT_NO_NAME_REF
const folly::IOBuf * front() const
void append(std::unique_ptr< folly::IOBuf > &&buf, bool pack=false)
void encodeInsertQ(const HPACKHeader &header, bool isStaticName, uint32_t nameIndex)
size_t chainLength() const
std::pair< bool, uint32_t > maybeDuplicate(uint32_t relativeIndex)
uint32_t encodeLiteral(folly::StringPiece literal)
std::unique_ptr< folly::IOBuf > release()
const uint8_t Q_DELTA_BASE_POS
HPACKEncodeBuffer controlBuffer_
bool shouldIndex(const HPACKHeader &header) const
void setHeaderIndexingStrategy(const HeaderIndexingStrategy *indexingStrat)
const Instruction Q_DUPLICATE
const Instruction Q_INDEXED_POST
constexpr detail::Map< Move > move
void encodeLiteralQHelper(HPACKEncodeBuffer &buffer, const HPACKHeader &header, bool isStaticName, uint32_t nameIndex, uint8_t staticFlag, const HPACK::Instruction &idxInstr, const HPACK::Instruction &litInstr)
const Instruction Q_LITERAL_NAME_REF_POST
HPACKEncodeBuffer streamBuffer_
void addHeadroom(uint32_t bytes)
HPACK::DecodeError onHeaderAck(uint64_t streamId, bool all)
void encodeDuplicate(uint32_t index)
const Instruction Q_LITERAL
void encodeStreamLiteralQ(const HPACKHeader &header, bool isStaticName, uint32_t nameIndex, uint32_t absoluteNameIndex, uint32_t baseIndex, uint32_t *largestReference)
OutstandingBlock * curOutstanding_
BlockReferences references
HPACK::DecodeError decodeDecoderStream(std::unique_ptr< folly::IOBuf > buf)
EncodeResult encode(const std::vector< HPACKHeader > &headers, uint32_t headroom, uint64_t streamId)
void trackReference(uint32_t index, uint32_t *largestReference)
QPACKEncoder(bool huffman, uint32_t tableSize=HPACK::kTableSize)
void encodeHeaderQ(const HPACKHeader &header, uint32_t baseIndex, uint32_t *largestReference)
bool allowVulnerable() const
const uint8_t Q_LITERAL_STATIC
const uint8_t Q_INSERT_NAME_REF_STATIC
void encodeLiteralQ(const HPACKHeader &header, bool isStaticName, bool postBase, uint32_t nameIndex, const HPACK::Instruction &idxInstr)
void handlePendingContextUpdate(HPACKEncodeBuffer &buf, uint32_t tableCapacity)
const Instruction Q_HEADER_ACK
const Instruction Q_INSERT_NAME_REF
uint32_t encodeInteger(uint64_t value, uint8_t instruction, uint8_t nbit)
const Instruction Q_DELTA_BASE
HPACK::DecodeError decodeHeaderAck(HPACKDecodeBuffer &dbuf, uint8_t prefixLength, bool all)
const StaticHeaderTable & getStaticTable() const
const uint8_t Q_INDEXED_STATIC
folly::IOBufQueue decoderIngress_
HPACK::DecodeError onTableStateSync(uint32_t inserts)
const HeaderIndexingStrategy * indexingStrat_
void trimStart(size_t amount)
HPACK::DecodeError decodeInteger(uint8_t nbit, uint64_t &integer)
const uint8_t Q_DELTA_BASE_NEG
std::unordered_map< uint64_t, std::list< OutstandingBlock > > outstanding_
std::tuple< bool, uint32_t, uint32_t > getNameIndexQ(const HPACKHeaderName &headerName)
const Instruction Q_INDEXED
const Instruction Q_LITERAL_NAME_REF
QPACKEncoder::EncodeResult encodeQ(const std::vector< HPACKHeader > &headers, uint64_t streamId)
const Instruction Q_CANCEL_STREAM
Composed all(Predicate pred=Predicate())