proxygen
HPACKEncodeBuffer.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/FBString.h>
13 #include <folly/io/Cursor.h>
14 #include <folly/io/IOBufQueue.h>
17 
18 namespace proxygen {
19 
21 
22  public:
24  uint32_t growthSize,
25  bool huffmanEnabled);
26 
27  explicit HPACKEncodeBuffer(uint32_t growthSize);
28 
30 
34  std::unique_ptr<folly::IOBuf> release() {
35  return bufQueue_.move();
36  }
37 
38  void clear() {
39  bufQueue_.clear();
40  }
41 
46  void addHeadroom(uint32_t bytes);
47 
64  uint32_t encodeInteger(uint64_t value, uint8_t instruction, uint8_t nbit);
65 
66  uint32_t encodeInteger(uint64_t value, const HPACK::Instruction& instruction);
67 
69 
76 
83  uint32_t encodeLiteral(uint8_t instruction, uint8_t nbit,
84  folly::StringPiece literal);
85 
90 
95  uint32_t encodeHuffman(uint8_t instruction, uint8_t nbit,
96  folly::StringPiece literal);
97 
101  std::string toBin();
102 
103  private:
104 
108  void append(uint8_t byte);
109 
114 };
115 
116 }
uint32_t encodeHuffman(folly::StringPiece literal)
HPACKEncodeBuffer(uint32_t growthSize, bool huffmanEnabled)
uint32_t encodeLiteral(folly::StringPiece literal)
std::unique_ptr< folly::IOBuf > release()
std::unique_ptr< folly::IOBuf > move()
Definition: IOBufQueue.h:459
void addHeadroom(uint32_t bytes)
uint32_t encodeInteger(uint64_t value, uint8_t instruction, uint8_t nbit)
static const char *const value
Definition: Conv.cpp:50
const char * string
Definition: Conv.cpp:212
folly::io::QueueAppender buf_