proxygen
proxygen::HTTPChecks Class Reference

#include <HTTPChecks.h>

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

Public Member Functions

void onHeadersComplete (StreamID stream, std::unique_ptr< HTTPMessage > msg) override
 
void generateHeader (folly::IOBufQueue &writeBuf, StreamID stream, const HTTPMessage &msg, bool eom, HTTPHeaderSize *sizeOut) 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)
 

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 Member Functions inherited from proxygen::GenericFilter< T1, T2, set_callback, TakeOwnership, Dp >
void setCallbackInternal (T2 *cb)
 
void drop ()
 
- 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 HTTPChecks.h.

Member Function Documentation

void proxygen::HTTPChecks::generateHeader ( folly::IOBufQueue writeBuf,
StreamID  stream,
const HTTPMessage msg,
bool  eom,
HTTPHeaderSize sizeOut 
)
override

Definition at line 35 of file HTTPChecks.cpp.

References proxygen::RFC2616::bodyImplied(), proxygen::GenericFilter< T1, T2, set_callback, TakeOwnership, Dp >::call_, proxygen::HTTPMessage::getHeaders(), proxygen::HTTPMessage::getMethod(), proxygen::HTTPMessage::isRequest(), proxygen::RFC2616::isRequestBodyAllowed(), and proxygen::RFC2616::NOT_ALLOWED.

39  {
40  if (msg.isRequest() && RFC2616::bodyImplied(msg.getHeaders())) {
41  CHECK(RFC2616::isRequestBodyAllowed(msg.getMethod()) !=
43  // We could also add a "strict" mode that disallows sending body on GET
44  // requests here too.
45  }
46 
47  call_->generateHeader(writeBuf, stream, msg, eom, sizeOut);
48 }
bool bodyImplied(const HTTPHeaders &headers)
Definition: RFC2616.cpp:59
BodyAllowed isRequestBodyAllowed(folly::Optional< HTTPMethod > method)
Definition: RFC2616.cpp:43
void proxygen::HTTPChecks::onHeadersComplete ( StreamID  stream,
std::unique_ptr< HTTPMessage msg 
)
override

Definition at line 16 of file HTTPChecks.cpp.

References proxygen::RFC2616::bodyImplied(), proxygen::GenericFilter< T1, T2, set_callback, TakeOwnership, Dp >::callback_, proxygen::HTTPException::INGRESS, proxygen::RFC2616::isRequestBodyAllowed(), proxygen::kErrorParseHeader, folly::gen::move, proxygen::RFC2616::NOT_ALLOWED, proxygen::HTTPException::setHttpStatusCode(), and proxygen::Exception::setProxygenError().

17  {
18 
19  if (msg->isRequest() && (RFC2616::isRequestBodyAllowed(msg->getMethod())
21  RFC2616::bodyImplied(msg->getHeaders())) {
22  HTTPException ex(
23  HTTPException::Direction::INGRESS, "RFC2616: Request Body Not Allowed");
24  ex.setProxygenError(kErrorParseHeader);
25  // setting the status code means that the error is at the HTTP layer and
26  // that parsing succeeded.
27  ex.setHttpStatusCode(400);
28  callback_->onError(stream, ex, true);
29  return;
30  }
31 
32  callback_->onHeadersComplete(stream, std::move(msg));
33 }
bool bodyImplied(const HTTPHeaders &headers)
Definition: RFC2616.cpp:59
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
BodyAllowed isRequestBodyAllowed(folly::Optional< HTTPMethod > method)
Definition: RFC2616.cpp:43

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