proxygen
proxygen::HPACKDecoderBase Class Reference

#include <HPACKDecoderBase.h>

Inheritance diagram for proxygen::HPACKDecoderBase:
proxygen::HPACKDecoder proxygen::QPACKDecoder

Public Types

using headers_t = std::vector< HPACKHeader >
 

Public Member Functions

 HPACKDecoderBase (uint32_t tableSize, uint32_t maxUncompressed)
 
HPACK::DecodeError getError () const
 
bool hasError () const
 
void setHeaderTableMaxSize (uint32_t maxSize)
 
void setMaxUncompressed (uint64_t maxUncompressed)
 

Protected Member Functions

uint32_t emit (const HPACKHeader &header, HPACK::StreamingCallback *streamingCb, headers_t *emitted)
 
void completeDecode (HeaderCodec::Type type, HPACK::StreamingCallback *streamingCb, uint32_t compressedSize, uint32_t emittedSize)
 
void handleTableSizeUpdate (HPACKDecodeBuffer &dbuf, HeaderTable &table)
 

Protected Attributes

HPACK::DecodeError err_ {HPACK::DecodeError::NONE}
 
uint32_t maxTableSize_
 
uint64_t maxUncompressed_
 

Detailed Description

Common decoder functionality between HPACK and QPACK

Definition at line 24 of file HPACKDecoderBase.h.

Member Typedef Documentation

Definition at line 32 of file HPACKDecoderBase.h.

Constructor & Destructor Documentation

proxygen::HPACKDecoderBase::HPACKDecoderBase ( uint32_t  tableSize,
uint32_t  maxUncompressed 
)
inline

Definition at line 26 of file HPACKDecoderBase.h.

29  : maxTableSize_(tableSize)
30  , maxUncompressed_(maxUncompressed) {}

Member Function Documentation

void proxygen::HPACKDecoderBase::completeDecode ( HeaderCodec::Type  type,
HPACK::StreamingCallback streamingCb,
uint32_t  compressedSize,
uint32_t  emittedSize 
)
protected

Definition at line 27 of file HPACKDecoderBase.cpp.

References wangle::HTTPHeaderSize::compressed, err_, proxygen::HPACK::HEADERS_TOO_LARGE, proxygen::HPACK::LITERAL_TOO_LARGE, proxygen::HPACK::NONE, proxygen::HPACK::StreamingCallback::onDecodeError(), proxygen::HPACK::StreamingCallback::onHeadersComplete(), proxygen::HeaderCodec::Stats::recordDecode(), proxygen::HeaderCodec::Stats::recordDecodeError(), proxygen::HeaderCodec::Stats::recordDecodeTooLarge(), proxygen::HPACK::StreamingCallback::stats, and wangle::HTTPHeaderSize::uncompressed.

Referenced by proxygen::QPACKDecoder::decodeStreaming(), proxygen::HPACKDecoder::decodeStreaming(), proxygen::QPACKDecoder::decodeStreamingImpl(), and setMaxUncompressed().

31  {
32  if (!streamingCb) {
33  return;
34  }
36  if (streamingCb->stats) {
39  streamingCb->stats->recordDecodeTooLarge(type);
40  } else {
41  streamingCb->stats->recordDecodeError(type);
42  }
43  }
44  streamingCb->onDecodeError(err_);
45  } else {
46  HTTPHeaderSize decodedSize;
47  decodedSize.compressed = compressedSize;
48  decodedSize.uncompressed = emittedSize;
49  if (streamingCb->stats) {
50  streamingCb->stats->recordDecode(type, decodedSize);
51  }
52  streamingCb->onHeadersComplete(decodedSize);
53  }
54 }
wangle::HTTPHeaderSize HTTPHeaderSize
PskType type
uint32_t proxygen::HPACKDecoderBase::emit ( const HPACKHeader header,
HPACK::StreamingCallback streamingCb,
headers_t emitted 
)
protected

Definition at line 15 of file HPACKDecoderBase.cpp.

References proxygen::HPACKHeader::bytes(), proxygen::HPACKHeaderName::get(), proxygen::HPACKHeader::name, proxygen::HPACK::StreamingCallback::onHeader(), and proxygen::HPACKHeader::value.

Referenced by proxygen::HPACKDecoder::decodeIndexedHeader(), proxygen::QPACKDecoder::decodeIndexedHeaderQ(), proxygen::HPACKDecoder::decodeLiteralHeader(), proxygen::QPACKDecoder::decodeLiteralHeaderQ(), and setMaxUncompressed().

17  {
18  if (streamingCb) {
19  streamingCb->onHeader(header.name.get(), header.value);
20  } else if (emitted) {
21  // copying HPACKHeader
22  emitted->emplace_back(header.name.get(), header.value);
23  }
24  return header.bytes();
25 }
HPACK::DecodeError proxygen::HPACKDecoderBase::getError ( ) const
inline

Definition at line 34 of file HPACKDecoderBase.h.

References err_.

Referenced by checkError(), and TEST_P().

34  {
35  return err_;
36  }
void proxygen::HPACKDecoderBase::handleTableSizeUpdate ( HPACKDecodeBuffer dbuf,
HeaderTable table 
)
protected

Definition at line 56 of file HPACKDecoderBase.cpp.

References proxygen::HPACKDecodeBuffer::decodeInteger(), err_, proxygen::ERROR, proxygen::HPACK::INVALID_TABLE_SIZE, maxTableSize_, proxygen::HPACK::NONE, proxygen::HeaderTable::setCapacity(), proxygen::HPACK::TABLE_SIZE_UPDATE, and uint64_t.

Referenced by proxygen::QPACKDecoder::decodeEncoderStreamInstruction(), proxygen::HPACKDecoder::decodeHeader(), and setMaxUncompressed().

57  {
58  uint64_t arg = 0;
59  err_ = dbuf.decodeInteger(HPACK::TABLE_SIZE_UPDATE.prefixLength, arg);
61  LOG(ERROR) << "Decode error decoding maxSize err_=" << err_;
62  return;
63  }
64 
65  if (arg > maxTableSize_) {
66  LOG(ERROR) << "Tried to increase size of the header table";
68  return;
69  }
70  VLOG(5) << "Received table size update, new size=" << arg;
71  table.setCapacity(arg);
72 }
const Instruction TABLE_SIZE_UPDATE
void proxygen::HPACKDecoderBase::setHeaderTableMaxSize ( uint32_t  maxSize)
inline

Definition at line 42 of file HPACKDecoderBase.h.

References maxTableSize_.

Referenced by TEST_P().

42  {
43  maxTableSize_ = maxSize;
44  }
void proxygen::HPACKDecoderBase::setMaxUncompressed ( uint64_t  maxUncompressed)
inline

Definition at line 46 of file HPACKDecoderBase.h.

References completeDecode(), emit(), handleTableSizeUpdate(), maxUncompressed_, type, and uint32_t.

Referenced by TEST().

46  {
47  maxUncompressed_ = maxUncompressed;
48  }

Member Data Documentation

uint32_t proxygen::HPACKDecoderBase::maxTableSize_
protected

Definition at line 64 of file HPACKDecoderBase.h.

Referenced by handleTableSizeUpdate(), and setHeaderTableMaxSize().


The documentation for this class was generated from the following files: