proxygen
HPACKDecoderBase.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018-present, Facebook, Inc.
3  * All rights reserved.
4  *
5  * This source code is licensed under the BSD-style license found in the
6  * LICENSE file in the root directory of this source tree. An additional grant
7  * of patent rights can be found in the PATENTS file in the same directory.
8  *
9  */
12 
13 namespace proxygen {
14 
16  HPACK::StreamingCallback* streamingCb,
17  headers_t* emitted) {
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 }
26 
29  HPACK::StreamingCallback* streamingCb,
30  uint32_t compressedSize,
31  uint32_t emittedSize) {
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 }
55 
57  HeaderTable& table) {
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 }
73 
74 }
std::vector< HPACKHeader > headers_t
PskType type
virtual void recordDecodeTooLarge(Type type)=0
void handleTableSizeUpdate(HPACKDecodeBuffer &dbuf, HeaderTable &table)
virtual void onHeadersComplete(HTTPHeaderSize decodedSize)=0
const Instruction TABLE_SIZE_UPDATE
uint32_t bytes() const
Definition: HPACKHeader.h:49
uint32_t emit(const HPACKHeader &header, HPACK::StreamingCallback *streamingCb, headers_t *emitted)
virtual void onHeader(const folly::fbstring &name, const folly::fbstring &value)=0
HPACKHeaderName name
Definition: HPACKHeader.h:82
virtual void recordDecode(Type type, HTTPHeaderSize &size)=0
virtual void recordDecodeError(Type type)=0
folly::fbstring value
Definition: HPACKHeader.h:83
void completeDecode(HeaderCodec::Type type, HPACK::StreamingCallback *streamingCb, uint32_t compressedSize, uint32_t emittedSize)
HPACK::DecodeError decodeInteger(uint8_t nbit, uint64_t &integer)
virtual bool setCapacity(uint32_t capacity)
virtual void onDecodeError(HPACK::DecodeError decodeError)=0
const std::string & get() const