proxygen
HTTPCodecFilter.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 
14 
15 namespace proxygen {
16 
17 typedef GenericFilter<
18  HTTPCodec,
19  HTTPCodec::Callback,
22 
29  public:
33  explicit PassThroughHTTPCodecFilter(bool calls = true,
34  bool callbacks = true):
35  HTTPCodecFilter(calls, callbacks) {}
36 
37  // HTTPCodec::Callback methods
38  void onMessageBegin(StreamID stream, HTTPMessage* msg) override;
39 
40  void onPushMessageBegin(StreamID stream, StreamID assocStream,
41  HTTPMessage* msg) override;
42 
43  void onExMessageBegin(StreamID stream, StreamID controlStream,
44  bool unidirectional, HTTPMessage* msg) override;
45 
46  void onHeadersComplete(StreamID stream,
47  std::unique_ptr<HTTPMessage> msg) override;
48 
49  void onBody(StreamID stream,
50  std::unique_ptr<folly::IOBuf> chain,
51  uint16_t padding) override;
52 
53  void onChunkHeader(StreamID stream, size_t length) override;
54 
55  void onChunkComplete(StreamID stream) override;
56 
57  void onTrailersComplete(StreamID stream,
58  std::unique_ptr<HTTPHeaders> trailers) override;
59 
60  void onMessageComplete(StreamID stream, bool upgrade) override;
61 
62  void onFrameHeader(StreamID stream_id,
63  uint8_t flags,
64  uint64_t length,
65  uint8_t type,
66  uint16_t version = 0) override;
67 
68  void onError(StreamID stream,
69  const HTTPException& error,
70  bool newStream = false) override;
71 
72  void onAbort(StreamID stream,
73  ErrorCode code) override;
74 
75  void onGoaway(uint64_t lastGoodStreamID,
76  ErrorCode code,
77  std::unique_ptr<folly::IOBuf> debugData = nullptr) override;
78 
79  void onPingRequest(uint64_t uniqueID) override;
80 
81  void onPingReply(uint64_t uniqueID) override;
82 
83  void onWindowUpdate(StreamID stream, uint32_t amount) override;
84 
85  void onSettings(const SettingsList& settings) override;
86 
87  void onSettingsAck() override;
88 
89  void onPriority(StreamID stream,
90  const HTTPMessage::HTTPPriority& pri) override;
91 
92  bool onNativeProtocolUpgrade(StreamID stream,
93  CodecProtocol protocol,
94  const std::string& protocolString,
95  HTTPMessage& msg) override;
96 
97  void onGenerateFrameHeader(StreamID streamID,
98  uint8_t type,
99  uint64_t length,
100  uint16_t version) override;
101 
102  void onCertificateRequest(uint16_t requestId,
103  std::unique_ptr<folly::IOBuf> authRequest) override;
104 
105  void onCertificate(uint16_t certId,
106  std::unique_ptr<folly::IOBuf> authenticator) override;
107 
108  uint32_t numOutgoingStreams() const override;
109 
110  uint32_t numIncomingStreams() const override;
111 
112  // HTTPCodec methods
113  HPACKTableInfo getHPACKTableInfo() const override;
114 
115  CodecProtocol getProtocol() const override;
116 
117  const std::string& getUserAgent() const override;
118 
119  TransportDirection getTransportDirection() const override;
120 
121  bool supportsStreamFlowControl() const override;
122 
123  bool supportsSessionFlowControl() const override;
124 
125  StreamID createStream() override;
126 
127  void setCallback(HTTPCodec::Callback* callback) override;
128 
129  bool isBusy() const override;
130 
131  void setParserPaused(bool paused) override;
132 
133  size_t onIngress(const folly::IOBuf& buf) override;
134 
135  void onIngressEOF() override;
136 
137  bool onIngressUpgradeMessage(const HTTPMessage& msg) override;
138 
139  bool isReusable() const override;
140 
141  bool isWaitingToDrain() const override;
142 
143  bool closeOnEgressComplete() const override;
144 
145  bool supportsParallelRequests() const override;
146 
147  bool supportsPushTransactions() const override;
148 
150 
151  void generateHeader(folly::IOBufQueue& writeBuf,
152  StreamID stream,
153  const HTTPMessage& msg,
154  bool eom,
155  HTTPHeaderSize* size) override;
156 
157  void generatePushPromise(folly::IOBufQueue& writeBuf,
158  StreamID stream,
159  const HTTPMessage& msg,
160  StreamID assocStream,
161  bool eom,
162  HTTPHeaderSize* size) override;
163 
164  void generateExHeader(folly::IOBufQueue& writeBuf,
165  StreamID stream,
166  const HTTPMessage& msg,
167  const HTTPCodec::ExAttributes& exAttributes,
168  bool eom,
169  HTTPHeaderSize* size) override;
170 
171  size_t generateBody(folly::IOBufQueue& writeBuf,
172  StreamID stream,
173  std::unique_ptr<folly::IOBuf> chain,
174  folly::Optional<uint8_t> padding,
175  bool eom) override;
176 
177  size_t generateChunkHeader(folly::IOBufQueue& writeBuf,
178  StreamID stream,
179  size_t length) override;
180 
182  StreamID stream) override;
183 
184  size_t generateTrailers(folly::IOBufQueue& writeBuf,
185  StreamID stream,
186  const HTTPHeaders& trailers) override;
187 
188  size_t generateEOM(folly::IOBufQueue& writeBuf,
189  StreamID stream) override;
190 
191  size_t generateRstStream(folly::IOBufQueue& writeBuf,
192  StreamID stream,
193  ErrorCode statusCode) override;
194 
195  size_t generateGoaway(
196  folly::IOBufQueue& writeBuf,
197  StreamID lastStream,
198  ErrorCode statusCode,
199  std::unique_ptr<folly::IOBuf> debugData = nullptr) override;
200 
201  size_t generatePingRequest(folly::IOBufQueue& writeBuf) override;
202 
203  size_t generatePingReply(folly::IOBufQueue& writeBuf,
204  uint64_t uniqueID) override;
205 
206  size_t generateSettings(folly::IOBufQueue& writeBuf) override;
207 
208  size_t generateSettingsAck(folly::IOBufQueue& writeBuf) override;
209 
210  size_t generateWindowUpdate(folly::IOBufQueue& writeBuf,
211  StreamID stream,
212  uint32_t delta) override;
213 
214  size_t generatePriority(folly::IOBufQueue& writeBuf,
215  StreamID stream,
216  const HTTPMessage::HTTPPriority& pri) override;
217 
219  folly::IOBufQueue& writeBuf,
220  uint16_t requestId,
221  std::unique_ptr<folly::IOBuf> chain) override;
222 
223  size_t generateCertificate(
224  folly::IOBufQueue& writeBuf,
225  uint16_t certId,
226  std::unique_ptr<folly::IOBuf> certData) override;
227 
228  HTTPSettings* getEgressSettings() override;
229 
230  const HTTPSettings* getIngressSettings() const override;
231 
232  void setHeaderCodecStats(HeaderCodec::Stats* stats) override;
233 
234  void enableDoubleGoawayDrain() override;
235 
237 
238  uint32_t getDefaultWindowSize() const override;
239 
240  size_t addPriorityNodes(
241  PriorityQueue& queue,
242  folly::IOBufQueue& writeBuf,
243  uint8_t maxLevel) override;
244 
245  StreamID mapPriorityToDependency(uint8_t priority) const override;
246 
247  int8_t mapDependencyToPriority(StreamID parent) const override;
248 };
249 
250 typedef FilterChain<
251  HTTPCodec,
252  HTTPCodec::Callback,
256 
257 }
size_t generateSettingsAck(folly::IOBufQueue &writeBuf) override
HTTPSettings * getEgressSettings() override
size_t onIngress(const folly::IOBuf &buf) override
flags
Definition: http_parser.h:127
spdy::GoawayStatusCode statusCode
Definition: SPDYCodec.cpp:110
size_t generateCertificate(folly::IOBufQueue &writeBuf, uint16_t certId, std::unique_ptr< folly::IOBuf > certData) override
void onChunkComplete(StreamID stream) override
void onPriority(StreamID stream, const HTTPMessage::HTTPPriority &pri) override
bool supportsPushTransactions() const override
size_t generateTrailers(folly::IOBufQueue &writeBuf, StreamID stream, const HTTPHeaders &trailers) override
virtual void setCallback(Callback *callback)=0
HTTPCodec::StreamID getLastIncomingStreamID() const override
size_t addPriorityNodes(PriorityQueue &queue, folly::IOBufQueue &writeBuf, uint8_t maxLevel) override
PskType type
FilterChain< HTTPCodec, HTTPCodec::Callback, PassThroughHTTPCodecFilter,&HTTPCodec::setCallback, true > HTTPCodecFilterChain
StreamID mapPriorityToDependency(uint8_t priority) const override
size_t generateRstStream(folly::IOBufQueue &writeBuf, StreamID stream, ErrorCode statusCode) override
size_t generateChunkTerminator(folly::IOBufQueue &writeBuf, StreamID stream) override
bool supportsSessionFlowControl() const override
void generatePushPromise(folly::IOBufQueue &writeBuf, StreamID stream, const HTTPMessage &msg, StreamID assocStream, bool eom, HTTPHeaderSize *size) override
bool supportsStreamFlowControl() const override
void setParserPaused(bool paused) override
size_t generatePriority(folly::IOBufQueue &writeBuf, StreamID stream, const HTTPMessage::HTTPPriority &pri) override
static http_parser_settings settings
Definition: test.c:1529
uint32_t numOutgoingStreams() const override
void onError(StreamID stream, const HTTPException &error, bool newStream=false) override
size_t generateSettings(folly::IOBufQueue &writeBuf) override
uint32_t numIncomingStreams() const override
size_t generateConnectionPreface(folly::IOBufQueue &writeBuf) override
void onFrameHeader(StreamID stream_id, uint8_t flags, uint64_t length, uint8_t type, uint16_t version=0) override
requires And< SemiMovable< VN >... > &&SemiMovable< E > auto error(E e)
Definition: error.h:48
HPACKTableInfo getHPACKTableInfo() const override
void onHeadersComplete(StreamID stream, std::unique_ptr< HTTPMessage > msg) override
size_t generateWindowUpdate(folly::IOBufQueue &writeBuf, StreamID stream, uint32_t delta) override
void onPingReply(uint64_t uniqueID) override
void setCallback(HTTPCodec::Callback *callback) override
ProtocolVersion version
size_t generateCertificateRequest(folly::IOBufQueue &writeBuf, uint16_t requestId, std::unique_ptr< folly::IOBuf > chain) override
constexpr auto size(C const &c) -> decltype(c.size())
Definition: Access.h:45
void writeBuf(const Buf &buf, folly::io::Appender &out)
void generateHeader(folly::IOBufQueue &writeBuf, StreamID stream, const HTTPMessage &msg, bool eom, HTTPHeaderSize *size) override
CodecProtocol getProtocol() const override
void onAbort(StreamID stream, ErrorCode code) override
bool supportsParallelRequests() const override
size_t generateBody(folly::IOBufQueue &writeBuf, StreamID stream, std::unique_ptr< folly::IOBuf > chain, folly::Optional< uint8_t > padding, bool eom) override
size_t generateEOM(folly::IOBufQueue &writeBuf, StreamID stream) override
void onSettings(const SettingsList &settings) override
PassThroughHTTPCodecFilter(bool calls=true, bool callbacks=true)
const std::string & getUserAgent() const override
void onBody(StreamID stream, std::unique_ptr< folly::IOBuf > chain, uint16_t padding) override
int8_t mapDependencyToPriority(StreamID parent) const override
bool closeOnEgressComplete() const override
bool onIngressUpgradeMessage(const HTTPMessage &msg) override
uint32_t getDefaultWindowSize() const override
std::tuple< uint32_t, bool, uint8_t > HTTPPriority
Definition: HTTPMessage.h:592
void onMessageComplete(StreamID stream, bool upgrade) override
size_t generatePingReply(folly::IOBufQueue &writeBuf, uint64_t uniqueID) override
std::vector< HTTPSetting > SettingsList
Definition: HTTPSettings.h:81
void onGoaway(uint64_t lastGoodStreamID, ErrorCode code, std::unique_ptr< folly::IOBuf > debugData=nullptr) override
void onPushMessageBegin(StreamID stream, StreamID assocStream, HTTPMessage *msg) override
void onCertificateRequest(uint16_t requestId, std::unique_ptr< folly::IOBuf > authRequest) override
const char * string
Definition: Conv.cpp:212
void onPingRequest(uint64_t uniqueID) override
size_t generatePingRequest(folly::IOBufQueue &writeBuf) override
void onChunkHeader(StreamID stream, size_t length) override
size_t generateGoaway(folly::IOBufQueue &writeBuf, StreamID lastStream, ErrorCode statusCode, std::unique_ptr< folly::IOBuf > debugData=nullptr) override
uint64_t StreamID
Definition: HTTPCodec.h:49
void onMessageBegin(StreamID stream, HTTPMessage *msg) override
void onTrailersComplete(StreamID stream, std::unique_ptr< HTTPHeaders > trailers) override
const HTTPSettings * getIngressSettings() const override
void generateExHeader(folly::IOBufQueue &writeBuf, StreamID stream, const HTTPMessage &msg, const HTTPCodec::ExAttributes &exAttributes, bool eom, HTTPHeaderSize *size) override
size_t generateChunkHeader(folly::IOBufQueue &writeBuf, StreamID stream, size_t length) override
void onExMessageBegin(StreamID stream, StreamID controlStream, bool unidirectional, HTTPMessage *msg) override
void setHeaderCodecStats(HeaderCodec::Stats *stats) override
uint32_t streamID
Definition: SPDYCodec.cpp:131
GenericFilter< HTTPCodec, HTTPCodec::Callback,&HTTPCodec::setCallback, true > HTTPCodecFilter
void onCertificate(uint16_t certId, std::unique_ptr< folly::IOBuf > authenticator) override
bool onNativeProtocolUpgrade(StreamID stream, CodecProtocol protocol, const std::string &protocolString, HTTPMessage &msg) override
void onWindowUpdate(StreamID stream, uint32_t amount) override
void onGenerateFrameHeader(StreamID streamID, uint8_t type, uint64_t length, uint16_t version) override
folly::Function< void()> parent
Definition: AtFork.cpp:34
TransportDirection getTransportDirection() const override