proxygen
HPACKEncoder.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015-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  */
10 #pragma once
11 
12 #include <folly/io/IOBuf.h>
15 #include <vector>
16 
17 namespace proxygen {
18 
19 class HPACKEncoder : public HPACKEncoderBase, public HPACKContext {
20 
21  public:
22  explicit HPACKEncoder(bool huffman,
23  uint32_t tableSize=HPACK::kTableSize)
24  : HPACKEncoderBase(huffman)
25  , HPACKContext(tableSize) {}
26 
31  std::unique_ptr<folly::IOBuf> encode(
32  const std::vector<HPACKHeader>& headers,
33  uint32_t headroom = 0);
34 
37  }
38 
39  private:
40  void encodeAsIndex(uint32_t index);
41 
42  void encodeHeader(const HPACKHeader& header);
43 
44  bool encodeAsLiteral(const HPACKHeader& header, bool indexing);
45 
46  void encodeLiteral(const HPACKHeader& header,
48  const HPACK::Instruction& instruction);
49 };
50 
51 }
const uint32_t kTableSize
void encodeAsIndex(uint32_t index)
bool encodeAsLiteral(const HPACKHeader &header, bool indexing)
void encodeLiteral(const HPACKHeader &header, uint32_t nameIndex, const HPACK::Instruction &instruction)
uint32_t nameIndex(const HPACKHeaderName &headerName) const
HPACKEncoder(bool huffman, uint32_t tableSize=HPACK::kTableSize)
Definition: HPACKEncoder.h:22
void encodeHeader(const HPACKHeader &header)
constexpr auto size(C const &c) -> decltype(c.size())
Definition: Access.h:45
void setHeaderTableSize(uint32_t size)
Definition: HPACKEncoder.h:35
std::unique_ptr< folly::IOBuf > encode(const std::vector< HPACKHeader > &headers, uint32_t headroom=0)
void setHeaderTableSize(HeaderTable &table, uint32_t size)