proxygen
proxygen::HTTPCodecPrinter Class Reference

#include <HTTPCodecPrinter.h>

Inheritance diagram for proxygen::HTTPCodecPrinter:
proxygen::PassThroughHTTPCodecFilter proxygen::GenericFilter< T1, T2, set_callback, TakeOwnership, Dp > T1 T2

Public Member Functions

void onFrameHeader (StreamID stream_id, uint8_t flags, uint64_t length, uint8_t type, uint16_t version=0) override
 
void onError (StreamID stream, const HTTPException &error, bool newStream=false) override
 
void onBody (StreamID stream, std::unique_ptr< folly::IOBuf > chain, uint16_t padding) override
 
void onMessageComplete (StreamID stream, bool upgrade) override
 
void onHeadersComplete (StreamID stream, std::unique_ptr< HTTPMessage > msg) override
 
void onAbort (StreamID stream, ErrorCode code) override
 
void onWindowUpdate (StreamID stream, uint32_t amount) override
 
void onSettings (const SettingsList &settings) override
 
void onSettingsAck () override
 
void onGoaway (uint64_t lastGoodStreamID, ErrorCode code, std::unique_ptr< folly::IOBuf > debugData=nullptr) override
 
void onPingRequest (uint64_t uniqueID) override
 
void onPingReply (uint64_t uniqueID) override
 
- Public Member Functions inherited from proxygen::PassThroughHTTPCodecFilter
 PassThroughHTTPCodecFilter (bool calls=true, bool callbacks=true)
 
void onMessageBegin (StreamID stream, HTTPMessage *msg) override
 
void onPushMessageBegin (StreamID stream, StreamID assocStream, HTTPMessage *msg) override
 
void onExMessageBegin (StreamID stream, StreamID controlStream, bool unidirectional, HTTPMessage *msg) override
 
void onHeadersComplete (StreamID stream, std::unique_ptr< HTTPMessage > msg) override
 
void onBody (StreamID stream, std::unique_ptr< folly::IOBuf > chain, uint16_t padding) override
 
void onChunkHeader (StreamID stream, size_t length) override
 
void onChunkComplete (StreamID stream) override
 
void onTrailersComplete (StreamID stream, std::unique_ptr< HTTPHeaders > trailers) override
 
void onMessageComplete (StreamID stream, bool upgrade) override
 
void onFrameHeader (StreamID stream_id, uint8_t flags, uint64_t length, uint8_t type, uint16_t version=0) override
 
void onError (StreamID stream, const HTTPException &error, bool newStream=false) override
 
void onAbort (StreamID stream, ErrorCode code) override
 
void onGoaway (uint64_t lastGoodStreamID, ErrorCode code, std::unique_ptr< folly::IOBuf > debugData=nullptr) override
 
void onPingRequest (uint64_t uniqueID) override
 
void onPingReply (uint64_t uniqueID) override
 
void onWindowUpdate (StreamID stream, uint32_t amount) override
 
void onSettings (const SettingsList &settings) override
 
void onSettingsAck () override
 
void onPriority (StreamID stream, const HTTPMessage::HTTPPriority &pri) override
 
bool onNativeProtocolUpgrade (StreamID stream, CodecProtocol protocol, const std::string &protocolString, HTTPMessage &msg) override
 
void onGenerateFrameHeader (StreamID streamID, uint8_t type, uint64_t length, uint16_t version) override
 
void onCertificateRequest (uint16_t requestId, std::unique_ptr< folly::IOBuf > authRequest) override
 
void onCertificate (uint16_t certId, std::unique_ptr< folly::IOBuf > authenticator) override
 
uint32_t numOutgoingStreams () const override
 
uint32_t numIncomingStreams () const override
 
HPACKTableInfo getHPACKTableInfo () const override
 
CodecProtocol getProtocol () const override
 
const std::stringgetUserAgent () const override
 
TransportDirection getTransportDirection () const override
 
bool supportsStreamFlowControl () const override
 
bool supportsSessionFlowControl () const override
 
StreamID createStream () override
 
void setCallback (HTTPCodec::Callback *callback) override
 
bool isBusy () const override
 
void setParserPaused (bool paused) override
 
size_t onIngress (const folly::IOBuf &buf) override
 
void onIngressEOF () override
 
bool onIngressUpgradeMessage (const HTTPMessage &msg) override
 
bool isReusable () const override
 
bool isWaitingToDrain () const override
 
bool closeOnEgressComplete () const override
 
bool supportsParallelRequests () const override
 
bool supportsPushTransactions () const override
 
size_t generateConnectionPreface (folly::IOBufQueue &writeBuf) override
 
void generateHeader (folly::IOBufQueue &writeBuf, StreamID stream, const HTTPMessage &msg, bool eom, HTTPHeaderSize *size) override
 
void generatePushPromise (folly::IOBufQueue &writeBuf, StreamID stream, const HTTPMessage &msg, StreamID assocStream, bool eom, HTTPHeaderSize *size) override
 
void generateExHeader (folly::IOBufQueue &writeBuf, StreamID stream, const HTTPMessage &msg, const HTTPCodec::ExAttributes &exAttributes, bool eom, HTTPHeaderSize *size) 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 generateChunkHeader (folly::IOBufQueue &writeBuf, StreamID stream, size_t length) override
 
size_t generateChunkTerminator (folly::IOBufQueue &writeBuf, StreamID stream) override
 
size_t generateTrailers (folly::IOBufQueue &writeBuf, StreamID stream, const HTTPHeaders &trailers) override
 
size_t generateEOM (folly::IOBufQueue &writeBuf, StreamID stream) override
 
size_t generateRstStream (folly::IOBufQueue &writeBuf, StreamID stream, ErrorCode statusCode) override
 
size_t generateGoaway (folly::IOBufQueue &writeBuf, StreamID lastStream, ErrorCode statusCode, std::unique_ptr< folly::IOBuf > debugData=nullptr) override
 
size_t generatePingRequest (folly::IOBufQueue &writeBuf) override
 
size_t generatePingReply (folly::IOBufQueue &writeBuf, uint64_t uniqueID) override
 
size_t generateSettings (folly::IOBufQueue &writeBuf) override
 
size_t generateSettingsAck (folly::IOBufQueue &writeBuf) override
 
size_t generateWindowUpdate (folly::IOBufQueue &writeBuf, StreamID stream, uint32_t delta) override
 
size_t generatePriority (folly::IOBufQueue &writeBuf, StreamID stream, const HTTPMessage::HTTPPriority &pri) override
 
size_t generateCertificateRequest (folly::IOBufQueue &writeBuf, uint16_t requestId, std::unique_ptr< folly::IOBuf > chain) override
 
size_t generateCertificate (folly::IOBufQueue &writeBuf, uint16_t certId, std::unique_ptr< folly::IOBuf > certData) override
 
HTTPSettingsgetEgressSettings () override
 
const HTTPSettingsgetIngressSettings () const override
 
void setHeaderCodecStats (HeaderCodec::Stats *stats) override
 
void enableDoubleGoawayDrain () override
 
HTTPCodec::StreamID getLastIncomingStreamID () const override
 
uint32_t getDefaultWindowSize () const override
 
size_t addPriorityNodes (PriorityQueue &queue, folly::IOBufQueue &writeBuf, uint8_t maxLevel) override
 
StreamID mapPriorityToDependency (uint8_t priority) const override
 
int8_t mapDependencyToPriority (StreamID parent) const override
 
- Public Member Functions inherited from proxygen::GenericFilter< T1, T2, set_callback, TakeOwnership, Dp >
 GenericFilter (bool calls, bool callbacks)
 
 ~GenericFilter () override
 
void append (Filter *nextFilter)
 

Protected Member Functions

void printPing (uint64_t uniqueID)
 
- Protected Member Functions inherited from proxygen::GenericFilter< T1, T2, set_callback, TakeOwnership, Dp >
void setCallbackInternal (T2 *cb)
 
void drop ()
 

Additional Inherited Members

- Public Types inherited from proxygen::GenericFilter< T1, T2, set_callback, TakeOwnership, Dp >
using Filter = GenericFilter< T1, T2, set_callback, TakeOwnership, Dp >
 
- Public Attributes inherited from proxygen::GenericFilter< T1, T2, set_callback, TakeOwnership, Dp >
const bool kWantsCalls_
 
const bool kWantsCallbacks_
 
- Protected Attributes inherited from proxygen::GenericFilter< T1, T2, set_callback, TakeOwnership, Dp >
T1call_ {nullptr}
 
T2callback_ {nullptr}
 

Detailed Description

This class enforces certain higher-level HTTP semantics. It does not enforce conditions that require state to decide. That is, this class is stateless and only examines the calls and callbacks that go through it.

Definition at line 22 of file HTTPCodecPrinter.h.

Member Function Documentation

void proxygen::HTTPCodecPrinter::onAbort ( StreamID  stream,
ErrorCode  code 
)
override

Definition at line 94 of file HTTPCodecPrinter.cpp.

References proxygen::GenericFilter< T1, T2, set_callback, TakeOwnership, Dp >::callback_, and proxygen::getErrorCodeString().

94  {
95  std::cout << "RST_STREAM: stream_id=" << stream << ", error="
96  << getErrorCodeString(code) << std::endl;
97  callback_->onAbort(stream, code);
98 }
const char * getErrorCodeString(ErrorCode error)
Definition: ErrorCode.cpp:18
void proxygen::HTTPCodecPrinter::onBody ( StreamID  stream,
std::unique_ptr< folly::IOBuf chain,
uint16_t  padding 
)
override

Definition at line 62 of file HTTPCodecPrinter.cpp.

References proxygen::GenericFilter< T1, T2, set_callback, TakeOwnership, Dp >::callback_, folly::IOBuf::length(), and folly::gen::move.

64  {
65  std::cout << "DataChunk: stream_id=" << stream
66  << ", length=" << chain->length()
67  << ", padding=" << padding << std::endl;
68  callback_->onBody(stream, std::move(chain), padding);
69 }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
std::size_t length() const
Definition: IOBuf.h:533
void proxygen::HTTPCodecPrinter::onError ( StreamID  stream,
const HTTPException error,
bool  newStream = false 
)
override

Definition at line 55 of file HTTPCodecPrinter.cpp.

References proxygen::GenericFilter< T1, T2, set_callback, TakeOwnership, Dp >::callback_, and proxygen::Exception::what().

57  {
58  std::cout << "[Exception] " << error.what() << std::endl;
59  callback_->onError(stream, error, newStream);
60 }
requires And< SemiMovable< VN >... > &&SemiMovable< E > auto error(E e)
Definition: error.h:48
void proxygen::HTTPCodecPrinter::onFrameHeader ( StreamID  stream_id,
uint8_t  flags,
uint64_t  length,
uint8_t  type,
uint16_t  version = 0 
)
override

Definition at line 16 of file HTTPCodecPrinter.cpp.

References proxygen::GenericFilter< T1, T2, set_callback, TakeOwnership, Dp >::call_, proxygen::GenericFilter< T1, T2, set_callback, TakeOwnership, Dp >::callback_, proxygen::HTTP_1_1, proxygen::HTTP_2, proxygen::SPDY_3, and proxygen::SPDY_3_1.

21  {
22  switch (call_->getProtocol()) {
25  if (version > 0) {
26  // Print frame header info of SPDY control frames
27  std::cout << "[CTRL FRAME] version=" << version << ", flags="
28  << std::hex << folly::to<unsigned int>(flags) << std::dec
29  << ", length=" << length
30  << ", type=" << type
31  << std::endl;
32  } else {
33  // Print frame header info of SPDY data frames and HTTP/2 frames
34  std::cout << "[DATA FRAME] stream_id=" << stream_id << ", flags="
35  << std::hex << folly::to<unsigned int>(flags) << std::dec
36  << ", length=" << length
37  << ", type=" << type
38  << std::endl;
39  }
40  break;
42  std::cout << "[FRAME] stream_id=" << stream_id << ", flags="
43  << std::hex << folly::to<unsigned int>(flags) << std::dec
44  << ", length=" << length
45  << ", type=" << type
46  << std::endl;
47  break;
49  default:
50  break;
51  }
52  callback_->onFrameHeader(stream_id, flags, length, type, version);
53 }
flags
Definition: http_parser.h:127
PskType type
ProtocolVersion version
void proxygen::HTTPCodecPrinter::onGoaway ( uint64_t  lastGoodStreamID,
ErrorCode  code,
std::unique_ptr< folly::IOBuf debugData = nullptr 
)
override

Definition at line 100 of file HTTPCodecPrinter.cpp.

References proxygen::GenericFilter< T1, T2, set_callback, TakeOwnership, Dp >::callback_, folly::IOBuf::data(), proxygen::getErrorCodeString(), folly::IOBuf::length(), folly::gen::move, and string.

101  {
102  std::string debugInfo = (debugData) ? ", debug info=" +
103  std::string((char*)debugData->data(), debugData->length()) : "";
104  std::cout << "GOAWAY: lastGoodStream=" << lastGoodStream
105  << ", error=" << getErrorCodeString(code) << debugInfo << std::endl;
106  callback_->onGoaway(lastGoodStream, code, std::move(debugData));
107 }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
const uint8_t * data() const
Definition: IOBuf.h:499
std::size_t length() const
Definition: IOBuf.h:533
const char * getErrorCodeString(ErrorCode error)
Definition: ErrorCode.cpp:18
const char * string
Definition: Conv.cpp:212
void proxygen::HTTPCodecPrinter::onHeadersComplete ( StreamID  stream,
std::unique_ptr< HTTPMessage msg 
)
override

Definition at line 76 of file HTTPCodecPrinter.cpp.

References proxygen::GenericFilter< T1, T2, set_callback, TakeOwnership, Dp >::callback_, folly::gen::move, string, and val.

78  {
79  std::cout << "HEADERS: stream_id=" << stream
80  << ", numHeaders=" << msg->getHeaders().size() << std::endl;
81  if (msg->isRequest()) {
82  std::cout << "URL=" << msg->getURL() << std::endl;
83  } else {
84  std::cout << "Status=" << msg->getStatusCode() << std::endl;
85  }
86  msg->getHeaders().forEach([&] (
87  const std::string& header,
88  const std::string& val) {
89  std::cout << "\t" << header << ": " << val << std::endl;
90  });
91  callback_->onHeadersComplete(stream, std::move(msg));
92 }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
double val
Definition: String.cpp:273
const char * string
Definition: Conv.cpp:212
void proxygen::HTTPCodecPrinter::onMessageComplete ( StreamID  stream,
bool  upgrade 
)
override

Definition at line 71 of file HTTPCodecPrinter.cpp.

References proxygen::GenericFilter< T1, T2, set_callback, TakeOwnership, Dp >::callback_.

71  {
72  std::cout << "DataComplete: stream_id=" << stream << std::endl;
73  callback_->onMessageComplete(stream, upgrade);
74 }
void proxygen::HTTPCodecPrinter::onPingReply ( uint64_t  uniqueID)
override

Definition at line 134 of file HTTPCodecPrinter.cpp.

References proxygen::GenericFilter< T1, T2, set_callback, TakeOwnership, Dp >::callback_, and printPing().

134  {
135  printPing(unique_id);
136  callback_->onPingReply(unique_id);
137 }
void printPing(uint64_t uniqueID)
void proxygen::HTTPCodecPrinter::onPingRequest ( uint64_t  uniqueID)
override

Definition at line 129 of file HTTPCodecPrinter.cpp.

References proxygen::GenericFilter< T1, T2, set_callback, TakeOwnership, Dp >::callback_, and printPing().

129  {
130  printPing(unique_id);
131  callback_->onPingRequest(unique_id);
132 }
void printPing(uint64_t uniqueID)
void proxygen::HTTPCodecPrinter::onSettings ( const SettingsList settings)
override

Definition at line 115 of file HTTPCodecPrinter.cpp.

References proxygen::GenericFilter< T1, T2, set_callback, TakeOwnership, Dp >::callback_.

115  {
116  std::cout << "SETTINGS: num=" << settings.size() << std::endl;
117  for (const auto& setting: settings) {
118  std::cout << "\tid=" << folly::to<uint16_t>(setting.id)
119  << ", value=" << setting.value << std::endl;
120  }
121  callback_->onSettings(settings);
122 }
static http_parser_settings settings
Definition: test.c:1529
void proxygen::HTTPCodecPrinter::onSettingsAck ( )
override

Definition at line 124 of file HTTPCodecPrinter.cpp.

References proxygen::GenericFilter< T1, T2, set_callback, TakeOwnership, Dp >::callback_.

124  {
125  std::cout << "SETTINGS_ACK" << std::endl;
126  callback_->onSettingsAck();
127 }
void proxygen::HTTPCodecPrinter::onWindowUpdate ( StreamID  stream,
uint32_t  amount 
)
override

Definition at line 109 of file HTTPCodecPrinter.cpp.

References proxygen::GenericFilter< T1, T2, set_callback, TakeOwnership, Dp >::callback_.

109  {
110  std::cout << "WINDOW_UPDATE: stream_id=" << stream
111  << ", delta_window_size=" << amount << std::endl;
112  callback_->onWindowUpdate(stream, amount);
113 }
void proxygen::HTTPCodecPrinter::printPing ( uint64_t  uniqueID)
protected

Definition at line 139 of file HTTPCodecPrinter.cpp.

Referenced by onPingReply(), and onPingRequest().

139  {
140  std::cout << "PING: unique_id=" << unique_id << std::endl;
141 }

The documentation for this class was generated from the following files: