proxygen
HeaderCodec.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 <memory>
13 #include <folly/Expected.h>
14 #include <folly/FBString.h>
18 #include <vector>
19 
20 namespace folly {
21 class IOBuf;
22 }
23 
24 namespace folly { namespace io {
25 class Cursor;
26 }}
27 
28 namespace proxygen {
29 
33 };
34 
35 class HeaderCodec {
36  public:
37  const static uint32_t kMaxUncompressed = 128 * 1024;
38 
39  enum class Type : uint8_t {
40  GZIP = 0,
41  HPACK = 1,
42  QPACK = 2
43  };
44 
45  class Stats {
46  public:
47  Stats() {}
48  virtual ~Stats() {}
49 
50  virtual void recordEncode(Type type, HTTPHeaderSize& size) = 0;
51  virtual void recordDecode(Type type, HTTPHeaderSize& size) = 0;
52  virtual void recordDecodeError(Type type) = 0;
53  virtual void recordDecodeTooLarge(Type type) = 0;
54  };
55 
57  virtual ~HeaderCodec() {}
58 
63  return encodedSize_;
64  }
65 
69  void setEncodeHeadroom(uint32_t headroom) {
70  encodeHeadroom_ = headroom;
71  }
72 
73  virtual void setMaxUncompressed(uint64_t maxUncompressed) {
74  maxUncompressed_ = maxUncompressed;
75  }
76 
78  return maxUncompressed_;
79  }
80 
84  void setStats(Stats* stats) {
85  stats_ = stats;
86  }
87 
88  protected:
89 
91  uint32_t encodeHeadroom_{0};
92  uint64_t maxUncompressed_{kMaxUncompressed};
93  Stats* stats_{nullptr};
94 };
95 
96 }
virtual ~HeaderCodec()
Definition: HeaderCodec.h:57
compress::HeaderPieceList & headers
Definition: HeaderCodec.h:31
PskType type
—— Concurrent Priority Queue Implementation ——
Definition: AtomicBitSet.h:29
HTTPHeaderSize encodedSize_
Definition: HeaderCodec.h:90
void setEncodeHeadroom(uint32_t headroom)
Definition: HeaderCodec.h:69
constexpr auto size(C const &c) -> decltype(c.size())
Definition: Access.h:45
uint64_t getMaxUncompressed() const
Definition: HeaderCodec.h:77
std::deque< HeaderPiece > HeaderPieceList
Definition: HeaderPiece.h:59
void setStats(Stats *stats)
Definition: HeaderCodec.h:84
virtual void setMaxUncompressed(uint64_t maxUncompressed)
Definition: HeaderCodec.h:73
const HTTPHeaderSize & getEncodedSize()
Definition: HeaderCodec.h:62