proxygen
HTTPCodecFilter.cpp
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  */
11 
12 namespace proxygen {
13 
14 // HTTPCodec::Callback methods
16  HTTPMessage* msg) {
17  callback_->onMessageBegin(stream, msg);
18 }
19 
21  StreamID assocStream,
22  HTTPMessage* msg) {
23  callback_->onPushMessageBegin(stream, assocStream, msg);
24 }
25 
27  StreamID controlStream,
28  bool unidirectional,
29  HTTPMessage* msg) {
30  callback_->onExMessageBegin(stream, controlStream, unidirectional, msg);
31 }
32 
34  StreamID stream,
35  std::unique_ptr<HTTPMessage> msg) {
36  callback_->onHeadersComplete(stream, std::move(msg));
37 }
38 
40  std::unique_ptr<folly::IOBuf> chain,
41  uint16_t padding) {
42  callback_->onBody(stream, std::move(chain), padding);
43 }
44 
46  size_t length) {
47  callback_->onChunkHeader(stream, length);
48 }
49 
51  callback_->onChunkComplete(stream);
52 }
53 
55  StreamID stream,
56  std::unique_ptr<HTTPHeaders> trailers) {
57  callback_->onTrailersComplete(stream, std::move(trailers));
58 }
59 
61  bool upgrade) {
62  callback_->onMessageComplete(stream, upgrade);
63 }
64 
66  StreamID stream_id,
67  uint8_t flags,
68  uint64_t length,
69  uint8_t type,
70  uint16_t version) {
71  callback_->onFrameHeader(stream_id, flags, length, type, version);
72 }
73 
75  StreamID stream,
76  const HTTPException& error,
77  bool newStream) {
78  callback_->onError(stream, error, newStream);
79 }
80 
82  ErrorCode code) {
83  callback_->onAbort(stream, code);
84 }
85 
87  uint64_t lastGoodStreamID,
88  ErrorCode code,
89  std::unique_ptr<folly::IOBuf> debugData) {
90  callback_->onGoaway(lastGoodStreamID, code, std::move(debugData));
91 }
92 
94  callback_->onPingRequest(uniqueID);
95 }
96 
98  callback_->onPingReply(uniqueID);
99 }
100 
102  uint32_t amount) {
103  callback_->onWindowUpdate(stream, amount);
104 }
105 
107  callback_->onSettings(settings);
108 }
109 
111  callback_->onSettingsAck();
112 }
113 
115  StreamID stream,
116  const HTTPMessage::HTTPPriority& pri) {
117  callback_->onPriority(stream, pri);
118 }
119 
121  StreamID streamID, CodecProtocol protocol, const std::string& protocolString,
122  HTTPMessage& msg) {
123  return callback_->onNativeProtocolUpgrade(streamID, protocol, protocolString,
124  msg);
125 }
126 
128  uint8_t type,
129  uint64_t length,
130  uint16_t version) {
131  callback_->onGenerateFrameHeader(streamID, length, type, version);
132 }
133 
135  uint16_t requestId, std::unique_ptr<folly::IOBuf> authRequest) {
136  callback_->onCertificateRequest(requestId, std::move(authRequest));
137 }
138 
140  uint16_t certId, std::unique_ptr<folly::IOBuf> authenticator) {
141  callback_->onCertificate(certId, std::move(authenticator));
142 }
143 
145  return callback_->numOutgoingStreams();
146 }
147 
149  return callback_->numIncomingStreams();
150 }
151 
152 // PassThroughHTTPCodec methods
154  return call_->getHPACKTableInfo();
155 }
156 
158  return call_->getProtocol();
159 }
160 
162  return call_->getUserAgent();
163 }
164 
166  return call_->getTransportDirection();
167 }
168 
170  return call_->supportsStreamFlowControl();
171 }
172 
174  return call_->supportsSessionFlowControl();
175 }
176 
178  return call_->createStream();
179 }
180 
182  setCallbackInternal(callback);
183 }
184 
186  return call_->isBusy();
187 }
188 
190  call_->setParserPaused(paused);
191 }
192 
194  return call_->onIngress(buf);
195 }
196 
198  call_->onIngressEOF();
199 }
200 
202  const HTTPMessage& msg) {
203  return call_->onIngressUpgradeMessage(msg);
204 }
205 
207  return call_->isReusable();
208 }
209 
211  return call_->isWaitingToDrain();
212 }
213 
215  return call_->closeOnEgressComplete();
216 }
217 
219  return call_->supportsParallelRequests();
220 }
221 
223  return call_->supportsPushTransactions();
224 }
225 
228  return call_->generateConnectionPreface(writeBuf);
229 }
230 
231 
233  StreamID stream,
234  const HTTPMessage& msg,
235  bool eom,
236  HTTPHeaderSize* size) {
237  return call_->generateHeader(writeBuf, stream, msg, eom, size);
238 }
239 
241  StreamID stream,
242  const HTTPMessage& msg,
243  StreamID assocStream,
244  bool eom,
245  HTTPHeaderSize* size) {
246  return call_->generatePushPromise(buf, stream, msg, assocStream, eom, size);
247 }
248 
250  StreamID stream,
251  const HTTPMessage& msg,
253  exAttributes,
254  bool eom,
255  HTTPHeaderSize* size) {
256  return call_->generateExHeader(writeBuf, stream, msg, exAttributes,
257  eom, size);
258 }
259 
262  StreamID stream,
263  std::unique_ptr<folly::IOBuf> chain,
264  folly::Optional<uint8_t> padding,
265  bool eom) {
266  return call_->generateBody(writeBuf, stream, std::move(chain), padding,
267  eom);
268 }
269 
272  StreamID stream,
273  size_t length) {
274  return call_->generateChunkHeader(writeBuf, stream, length);
275 }
276 
279  StreamID stream) {
280  return call_->generateChunkTerminator(writeBuf, stream);
281 }
282 
285  StreamID stream,
286  const HTTPHeaders& trailers) {
287  return call_->generateTrailers(writeBuf, stream, trailers);
288 }
289 
291  StreamID stream) {
292  return call_->generateEOM(writeBuf, stream);
293 }
294 
297  StreamID stream,
298  ErrorCode code) {
299  return call_->generateRstStream(writeBuf, stream, code);
300 }
301 
304  StreamID lastStream,
306  std::unique_ptr<folly::IOBuf> debugData) {
307  return call_->generateGoaway(writeBuf, lastStream, statusCode,
308  std::move(debugData));
309 }
310 
313  return call_->generatePingRequest(writeBuf);
314 }
315 
318  uint64_t uniqueID) {
319  return call_->generatePingReply(writeBuf, uniqueID);
320 }
321 
323  return call_->generateSettings(buf);
324 }
325 
327  return call_->generateSettingsAck(buf);
328 }
329 
331  folly::IOBufQueue& buf,
332  StreamID stream,
333  uint32_t delta) {
334  return call_->generateWindowUpdate(buf, stream, delta);
335 }
336 
339  StreamID stream,
340  const HTTPMessage::HTTPPriority& pri) {
341  return call_->generatePriority(writeBuf, stream, pri);
342 }
343 
346  uint16_t requestId,
347  std::unique_ptr<folly::IOBuf> chain) {
348  return call_->generateCertificateRequest(
349  writeBuf, requestId, std::move(chain));
350 }
351 
354  uint16_t certId,
355  std::unique_ptr<folly::IOBuf> certData) {
356  return call_->generateCertificate(writeBuf, certId, std::move(certData));
357 }
358 
360  return call_->getEgressSettings();
361 }
362 
364  return call_->getIngressSettings();
365 }
366 
368  return call_->enableDoubleGoawayDrain();
369 }
370 
372  HeaderCodec::Stats* stats) {
373  call_->setHeaderCodecStats(stats);
374 }
375 
378  return call_->getLastIncomingStreamID();
379 }
380 
382  return call_->getDefaultWindowSize();
383 }
384 
385 size_t
387  PriorityQueue& queue,
389  uint8_t maxLevel) {
390  return call_->addPriorityNodes(queue, writeBuf, maxLevel);
391 }
392 
395  return call_->mapPriorityToDependency(priority);
396 }
397 
398 int8_t
400  return call_->mapDependencyToPriority(parent);
401 }
402 
403 }
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
HTTPCodec::StreamID getLastIncomingStreamID() const override
size_t addPriorityNodes(PriorityQueue &queue, folly::IOBufQueue &writeBuf, uint8_t maxLevel) override
PskType type
StreamID mapPriorityToDependency(uint8_t priority) const override
size_t generateRstStream(folly::IOBufQueue &writeBuf, StreamID stream, ErrorCode statusCode) override
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
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 setCallbackInternal(T2 *cb)
Definition: FilterChain.h:111
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
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
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