proxygen
|
#include <Filters.h>
Public Member Functions | |
Filter (RequestHandler *upstream) | |
void | setResponseHandler (ResponseHandler *handler) noexceptoverride |
void | onRequest (std::unique_ptr< HTTPMessage > headers) noexceptoverride |
void | onBody (std::unique_ptr< folly::IOBuf > body) noexceptoverride |
void | onUpgrade (UpgradeProtocol protocol) noexceptoverride |
void | onEOM () noexceptoverride |
void | requestComplete () noexceptoverride |
void | onError (ProxygenError err) noexceptoverride |
void | onEgressPaused () noexceptoverride |
void | onEgressResumed () noexceptoverride |
bool | canHandleExpect () noexceptoverride |
ExMessageHandler * | getExHandler () noexceptoverride |
void | sendHeaders (HTTPMessage &msg) noexceptoverride |
void | sendChunkHeader (size_t len) noexceptoverride |
void | sendBody (std::unique_ptr< folly::IOBuf > body) noexceptoverride |
void | sendChunkTerminator () noexceptoverride |
void | sendEOM () noexceptoverride |
void | sendAbort () noexceptoverride |
void | refreshTimeout () noexceptoverride |
void | pauseIngress () noexceptoverride |
void | resumeIngress () noexceptoverride |
ResponseHandler * | newPushedResponse (PushHandler *handler) noexceptoverride |
const wangle::TransportInfo & | getSetupTransportInfo () const noexceptoverride |
void | getCurrentTransportInfo (wangle::TransportInfo *tinfo) const override |
Public Member Functions inherited from proxygen::RequestHandler | |
virtual ResponseHandler * | getDownstream () noexcept |
virtual | ~RequestHandler () |
Public Member Functions inherited from proxygen::ResponseHandler | |
ResponseHandler (RequestHandler *upstream) | |
virtual | ~ResponseHandler () |
virtual ResponseHandler * | newExMessage (ExMessageHandler *, bool=false) noexcept |
HTTPTransaction * | getTransaction () const noexcept |
Additional Inherited Members | |
Protected Attributes inherited from proxygen::RequestHandler | |
ResponseHandler * | downstream_ {nullptr} |
Protected Attributes inherited from proxygen::ResponseHandler | |
RequestHandler * | upstream_ {nullptr} |
HTTPTransaction * | txn_ {nullptr} |
Filters are a way to add functionality to HTTPServer without complicating app specific RequestHandler. The basic idea is
App-handler <=> Filter-1 <=> Filter-2 <=> Client
The data flows through these filters between client and handler. They can do things like modify the data flowing through them, can update stats, create traces and even send direct response if they feel like.
The default implementation just lets everything pass through.
|
inlineexplicit |
Definition at line 31 of file Filters.h.
|
inlineoverridevirtualnoexcept |
Returns true if the handler is responsible for responding to Expect headers, false otherwise.
Reimplemented from proxygen::RequestHandler.
Definition at line 79 of file Filters.h.
References proxygen::RequestHandler::canHandleExpect(), and proxygen::ResponseHandler::upstream_.
|
inlineoverridevirtual |
Implements proxygen::ResponseHandler.
Definition at line 132 of file Filters.h.
References proxygen::RequestHandler::downstream_, and proxygen::ResponseHandler::getCurrentTransportInfo().
|
inlineoverridevirtualnoexcept |
Implement in control stream handler to support incoming child EX streams.
Reimplemented from proxygen::RequestHandler.
Definition at line 83 of file Filters.h.
References proxygen::RequestHandler::getExHandler(), and proxygen::ResponseHandler::upstream_.
|
inlineoverridevirtualnoexcept |
Implements proxygen::ResponseHandler.
Definition at line 128 of file Filters.h.
References proxygen::RequestHandler::downstream_, and proxygen::ResponseHandler::getSetupTransportInfo().
|
inlineoverridevirtualnoexcept |
Implements proxygen::ResponseHandler.
Definition at line 124 of file Filters.h.
References proxygen::RequestHandler::downstream_, handler(), and proxygen::ResponseHandler::newPushedResponse().
|
inlineoverridevirtualnoexcept |
Invoked when we get part of body for the request.
Implements proxygen::RequestHandler.
Definition at line 47 of file Filters.h.
References folly::gen::move, proxygen::RequestHandler::onBody(), and proxygen::ResponseHandler::upstream_.
|
inlineoverridevirtualnoexcept |
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 from proxygen::RequestHandler.
Definition at line 71 of file Filters.h.
References proxygen::RequestHandler::onEgressPaused(), and proxygen::ResponseHandler::upstream_.
|
inlineoverridevirtualnoexcept |
Reimplemented from proxygen::RequestHandler.
Definition at line 75 of file Filters.h.
References proxygen::RequestHandler::onEgressResumed(), and proxygen::ResponseHandler::upstream_.
|
inlineoverridevirtualnoexcept |
Invoked when we finish receiving the body.
Implements proxygen::RequestHandler.
Definition at line 55 of file Filters.h.
References proxygen::RequestHandler::onEOM(), and proxygen::ResponseHandler::upstream_.
|
inlineoverridevirtualnoexcept |
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.
Implements proxygen::RequestHandler.
Definition at line 65 of file Filters.h.
References proxygen::RequestHandler::downstream_, proxygen::RequestHandler::onError(), and proxygen::ResponseHandler::upstream_.
|
inlineoverridevirtualnoexcept |
Invoked when we have successfully fetched headers from client. This will always be the first callback invoked on your handler.
Implements proxygen::RequestHandler.
Definition at line 43 of file Filters.h.
References folly::gen::move, proxygen::RequestHandler::onRequest(), and proxygen::ResponseHandler::upstream_.
|
inlineoverridevirtualnoexcept |
Invoked when the session has been upgraded to a different protocol
Implements proxygen::RequestHandler.
Definition at line 51 of file Filters.h.
References proxygen::RequestHandler::onUpgrade(), and proxygen::ResponseHandler::upstream_.
|
inlineoverridevirtualnoexcept |
Implements proxygen::ResponseHandler.
Definition at line 116 of file Filters.h.
References proxygen::RequestHandler::downstream_, and proxygen::ResponseHandler::pauseIngress().
|
inlineoverridevirtualnoexcept |
Implements proxygen::ResponseHandler.
Definition at line 112 of file Filters.h.
References proxygen::RequestHandler::downstream_, and proxygen::ResponseHandler::refreshTimeout().
|
inlineoverridevirtualnoexcept |
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.
Implements proxygen::RequestHandler.
Definition at line 59 of file Filters.h.
References proxygen::RequestHandler::downstream_, proxygen::RequestHandler::requestComplete(), and proxygen::ResponseHandler::upstream_.
|
inlineoverridevirtualnoexcept |
Implements proxygen::ResponseHandler.
Definition at line 120 of file Filters.h.
References proxygen::RequestHandler::downstream_, and proxygen::ResponseHandler::resumeIngress().
|
inlineoverridevirtualnoexcept |
Implements proxygen::ResponseHandler.
Definition at line 108 of file Filters.h.
References proxygen::RequestHandler::downstream_, and proxygen::ResponseHandler::sendAbort().
Referenced by proxygen::ZlibServerFilter::fail().
|
inlineoverridevirtualnoexcept |
Implements proxygen::ResponseHandler.
Definition at line 96 of file Filters.h.
References proxygen::RequestHandler::downstream_, folly::gen::move, and proxygen::ResponseHandler::sendBody().
Referenced by proxygen::ZlibServerFilter::sendBody(), and proxygen::ZlibServerFilter::sendEOM().
|
inlineoverridevirtualnoexcept |
Implements proxygen::ResponseHandler.
Definition at line 92 of file Filters.h.
References proxygen::RequestHandler::downstream_, and proxygen::ResponseHandler::sendChunkHeader().
Referenced by proxygen::ZlibServerFilter::sendBody(), proxygen::ZlibServerFilter::sendChunkHeader(), and proxygen::ZlibServerFilter::sendEOM().
|
inlineoverridevirtualnoexcept |
Implements proxygen::ResponseHandler.
Definition at line 100 of file Filters.h.
References proxygen::RequestHandler::downstream_, and proxygen::ResponseHandler::sendChunkTerminator().
Referenced by proxygen::ZlibServerFilter::sendEOM().
|
inlineoverridevirtualnoexcept |
Implements proxygen::ResponseHandler.
Definition at line 104 of file Filters.h.
References proxygen::RequestHandler::downstream_, and proxygen::ResponseHandler::sendEOM().
Referenced by proxygen::ZlibServerFilter::sendEOM().
|
inlineoverridevirtualnoexcept |
NOTE: We take response message as non-const reference, to allow filters between your handler and client to be able to modify response if they want to.
eg. a compression filter might want to change the content-encoding
Implements proxygen::ResponseHandler.
Definition at line 88 of file Filters.h.
References proxygen::RequestHandler::downstream_, and proxygen::ResponseHandler::sendHeaders().
Referenced by proxygen::ZlibServerFilter::sendBody(), and proxygen::ZlibServerFilter::sendHeaders().
|
inlineoverridevirtualnoexcept |
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 from proxygen::RequestHandler.
Definition at line 36 of file Filters.h.
References proxygen::RequestHandler::downstream_, handler(), proxygen::RequestHandler::setResponseHandler(), proxygen::ResponseHandler::txn_, and proxygen::ResponseHandler::upstream_.