proxygen
proxygen::RequestHandler Class Referenceabstract

#include <RequestHandler.h>

Inheritance diagram for proxygen::RequestHandler:
EchoService::EchoHandler proxygen::DirectResponseHandler proxygen::ExMessageHandler proxygen::Filter proxygen::MockRequestHandler proxygen::PushHandler proxygen::ScopedHandler< HandlerType > ProxyService::ProxyHandler PushService::PushRequestHandler StaticService::StaticHandler TestHandlerFactory::TestHandler

Public Member Functions

virtual void setResponseHandler (ResponseHandler *handler) noexcept
 
virtual void onRequest (std::unique_ptr< HTTPMessage > headers) noexcept=0
 
virtual void onBody (std::unique_ptr< folly::IOBuf > body) noexcept=0
 
virtual void onUpgrade (proxygen::UpgradeProtocol prot) noexcept=0
 
virtual void onEOM () noexcept=0
 
virtual void requestComplete () noexcept=0
 
virtual void onError (ProxygenError err) noexcept=0
 
virtual void onEgressPaused () noexcept
 
virtual void onEgressResumed () noexcept
 
virtual bool canHandleExpect () noexcept
 
virtual ExMessageHandlergetExHandler () noexcept
 
virtual ResponseHandlergetDownstream () noexcept
 
virtual ~RequestHandler ()
 

Protected Attributes

ResponseHandlerdownstream_ {nullptr}
 

Detailed Description

Interface to be implemented by objects that handle requests from client. ResponseHandler acts as the client for these objects and provides methods to send back the response

Definition at line 24 of file RequestHandler.h.

Constructor & Destructor Documentation

virtual proxygen::RequestHandler::~RequestHandler ( )
inlinevirtual

Definition at line 109 of file RequestHandler.h.

109 {}

Member Function Documentation

virtual bool proxygen::RequestHandler::canHandleExpect ( )
inlinevirtualnoexcept

Returns true if the handler is responsible for responding to Expect headers, false otherwise.

Reimplemented in proxygen::Filter.

Definition at line 94 of file RequestHandler.h.

Referenced by proxygen::Filter::canHandleExpect(), and proxygen::RequestHandlerAdaptor::onHeadersComplete().

94  {
95  return false;
96  }
virtual ResponseHandler* proxygen::RequestHandler::getDownstream ( )
inlinevirtualnoexcept

Definition at line 105 of file RequestHandler.h.

References downstream_.

105  {
106  return downstream_;
107  }
ResponseHandler * downstream_
virtual ExMessageHandler* proxygen::RequestHandler::getExHandler ( )
inlinevirtualnoexcept

Implement in control stream handler to support incoming child EX streams.

Reimplemented in proxygen::Filter, and proxygen::ExMessageHandler.

Definition at line 101 of file RequestHandler.h.

Referenced by proxygen::Filter::getExHandler(), and proxygen::RequestHandlerAdaptor::onExTransaction().

101  {
102  LOG(FATAL) << "Not implemented";
103  }
virtual void proxygen::RequestHandler::onEgressPaused ( )
inlinevirtualnoexcept

Signals from HTTP layer when client queue is full or empty. If you are sending a streaming response, consider implementing these and acting accordingly. Saves your server from running out of memory.

Reimplemented in proxygen::Filter, proxygen::RejectConnectFilter, ProxyService::ProxyHandler, and StaticService::StaticHandler.

Definition at line 84 of file RequestHandler.h.

Referenced by proxygen::PushHandler::InnerPushHandler::onEgressPaused(), proxygen::RequestHandlerAdaptor::onEgressPaused(), and proxygen::Filter::onEgressPaused().

84  {
85  }
virtual void proxygen::RequestHandler::onEgressResumed ( )
inlinevirtualnoexcept
virtual void proxygen::RequestHandler::onError ( ProxygenError  err)
pure virtualnoexcept

Request failed. Maybe because of read/write error on socket or client not being able to send request in time.

NOTE: Can be invoked at any time (except for before onRequest).

No more callbacks will be invoked after this. You should clean up after yourself.

Implemented in TestHandlerFactory::TestHandler, proxygen::Filter, proxygen::ScopedHandler< HandlerType >, proxygen::DirectResponseHandler, ProxyService::ProxyHandler, proxygen::RejectConnectFilter, EchoService::EchoHandler, PushService::PushRequestHandler, StaticService::StaticHandler, and proxygen::PushHandler.

Referenced by proxygen::RejectConnectFilter::onError(), proxygen::Filter::onError(), proxygen::RejectConnectFilter::onRequest(), proxygen::RequestHandlerAdaptor::setError(), and setResponseHandler().

virtual void proxygen::RequestHandler::requestComplete ( )
pure virtualnoexcept

Invoked when request processing has been completed and nothing more needs to be done. This may be a good place to log some stats and clean up resources. This is distinct from onEOM() because it is invoked after the response is fully sent. Once this callback has been received, downstream_ should be considered invalid.

Implemented in TestHandlerFactory::TestHandler, proxygen::Filter, proxygen::ScopedHandler< HandlerType >, ProxyService::ProxyHandler, proxygen::DirectResponseHandler, proxygen::RejectConnectFilter, EchoService::EchoHandler, PushService::PushRequestHandler, StaticService::StaticHandler, and proxygen::PushHandler.

Referenced by proxygen::RequestHandlerAdaptor::detachTransaction(), proxygen::Filter::requestComplete(), and setResponseHandler().

virtual void proxygen::RequestHandler::setResponseHandler ( ResponseHandler handler)
inlinevirtualnoexcept

Saves the downstream handle with itself. Implementations of this interface should use downstream_ to send back response.

XXX: Only override this method if you are ABSOLUTELY sure what you are doing. If possible, just use downstream_ variable and dont mess with these things.

Reimplemented in proxygen::Filter.

Definition at line 34 of file RequestHandler.h.

References downstream_, handler(), folly::pushmi::__adl::noexcept(), onBody(), onEOM(), onError(), onRequest(), onUpgrade(), and requestComplete().

Referenced by proxygen::Filter::setResponseHandler(), and proxygen::RequestHandlerAdaptor::setTransaction().

34  {
35  downstream_ = CHECK_NOTNULL(handler);
36  }
void handler(int, siginfo_t *, void *)
ResponseHandler * downstream_

Member Data Documentation

ResponseHandler* proxygen::RequestHandler::downstream_ {nullptr}
protected

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