proxygen
|
#include <RequestHandlerAdaptor.h>
Public Member Functions | |
RequestHandlerAdaptor (RequestHandler *requestHandler) | |
Public Member Functions inherited from proxygen::HTTPTransactionHandler | |
virtual void | onPushedTransaction (HTTPTransaction *) noexcept |
virtual void | onGoaway (ErrorCode) noexcept |
virtual | ~HTTPTransactionHandler () |
Public Member Functions inherited from proxygen::ResponseHandler | |
ResponseHandler (RequestHandler *upstream) | |
virtual | ~ResponseHandler () |
HTTPTransaction * | getTransaction () const noexcept |
Private Member Functions | |
void | setTransaction (HTTPTransaction *txn) noexceptoverride |
void | detachTransaction () noexceptoverride |
void | onHeadersComplete (std::unique_ptr< HTTPMessage > msg) noexceptoverride |
void | onBody (std::unique_ptr< folly::IOBuf > chain) noexceptoverride |
void | onChunkHeader (size_t length) noexceptoverride |
void | onChunkComplete () noexceptoverride |
void | onTrailers (std::unique_ptr< HTTPHeaders > trailers) noexceptoverride |
void | onEOM () noexceptoverride |
void | onUpgrade (UpgradeProtocol protocol) noexceptoverride |
void | onError (const HTTPException &error) noexceptoverride |
void | onEgressPaused () noexceptoverride |
void | onEgressResumed () noexceptoverride |
void | onExTransaction (HTTPTransaction *txn) 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 *pushHandler) noexceptoverride |
ResponseHandler * | newExMessage (ExMessageHandler *exHandler, bool unidirectional) noexceptoverride |
const wangle::TransportInfo & | getSetupTransportInfo () const noexceptoverride |
void | getCurrentTransportInfo (wangle::TransportInfo *tinfo) const override |
void | setError (ProxygenError err) noexcept |
Private Attributes | |
ProxygenError | err_ {kErrorNone} |
Additional Inherited Members | |
Protected Attributes inherited from proxygen::ResponseHandler | |
RequestHandler * | upstream_ {nullptr} |
HTTPTransaction * | txn_ {nullptr} |
An adaptor that converts HTTPTransactionHandler to RequestHandler. Apart from that it also -
Handles all the error cases itself as described below. It makes a terminal call onError(...) where you are expected to log something and stop processing the request if you have started so.
onError - Send a direct response back if no response has started and writing is still possible. Otherwise sends an abort.
Definition at line 35 of file RequestHandlerAdaptor.h.
|
explicit |
Definition at line 20 of file RequestHandlerAdaptor.cpp.
Referenced by newExMessage(), newPushedResponse(), and onExTransaction().
|
overrideprivatevirtualnoexcept |
Called once after a transaction successfully completes. It will be called even if a read or write error happened earlier. This is a terminal callback, which means that the HTTPTransaction object that gives this call will be invalid after this function completes.
Implements proxygen::HTTPTransactionHandler.
Definition at line 31 of file RequestHandlerAdaptor.cpp.
References err_, proxygen::kErrorNone, proxygen::RequestHandler::requestComplete(), and proxygen::ResponseHandler::upstream_.
|
overrideprivatevirtual |
Implements proxygen::ResponseHandler.
Definition at line 202 of file RequestHandlerAdaptor.cpp.
References proxygen::HTTPTransaction::getCurrentTransportInfo(), and proxygen::ResponseHandler::txn_.
|
overrideprivatevirtualnoexcept |
Implements proxygen::ResponseHandler.
Definition at line 198 of file RequestHandlerAdaptor.cpp.
References proxygen::HTTPTransaction::getSetupTransportInfo(), and proxygen::ResponseHandler::txn_.
|
overrideprivatevirtualnoexcept |
Reimplemented from proxygen::ResponseHandler.
Definition at line 189 of file RequestHandlerAdaptor.cpp.
References proxygen::ResponseHandler::getTransaction(), handler(), proxygen::HTTPTransaction::newExTransaction(), and RequestHandlerAdaptor().
|
overrideprivatevirtualnoexcept |
Implements proxygen::ResponseHandler.
Definition at line 177 of file RequestHandlerAdaptor.cpp.
References proxygen::HTTPTransaction::newPushedTransaction(), RequestHandlerAdaptor(), and proxygen::ResponseHandler::txn_.
|
overrideprivatevirtualnoexcept |
Can be called multiple times per transaction. If you had previously called pauseIngress(), this callback will be delayed until you call resumeIngress().
Implements proxygen::HTTPTransactionHandler.
Definition at line 67 of file RequestHandlerAdaptor.cpp.
References c, folly::gen::move, proxygen::RequestHandler::onBody(), and proxygen::ResponseHandler::upstream_.
|
overrideprivatevirtualnoexcept |
Can be called multiple times per transaction. If you had previously called pauseIngress(), this callback will be delayed until you call resumeIngress(). This signifies the end of a chunk.
Reimplemented from proxygen::HTTPTransactionHandler.
Definition at line 73 of file RequestHandlerAdaptor.cpp.
|
overrideprivatevirtualnoexcept |
Can be called multiple times per transaction. If you had previously called pauseIngress(), this callback will be delayed until you call resumeIngress(). This signifies the beginning of a chunk of length 'length'. You will receive onBody() after this. Also, the length will be greater than zero.
Reimplemented from proxygen::HTTPTransactionHandler.
Definition at line 71 of file RequestHandlerAdaptor.cpp.
|
overrideprivatevirtualnoexcept |
If the remote side's receive buffer fills up, this callback will be invoked so you can attempt to stop sending to the remote side.
Implements proxygen::HTTPTransactionHandler.
Definition at line 127 of file RequestHandlerAdaptor.cpp.
References proxygen::RequestHandler::onEgressPaused(), and proxygen::ResponseHandler::upstream_.
|
overrideprivatevirtualnoexcept |
This callback lets you know that the remote side has resumed reading and you can now continue to send data.
Implements proxygen::HTTPTransactionHandler.
Definition at line 131 of file RequestHandlerAdaptor.cpp.
References proxygen::RequestHandler::onEgressResumed(), and proxygen::ResponseHandler::upstream_.
|
overrideprivatevirtualnoexcept |
Can be called once per transaction. If you had previously called pauseIngress(), this callback will be delayed until you call resumeIngress(). After this callback is received, there will be no more normal ingress callbacks received (onEgress*() and onError() may still be invoked). The Handler should consider ingress complete after receiving this message. This Transaction is still valid, and work may still occur on it until detachTransaction is called.
Implements proxygen::HTTPTransactionHandler.
Definition at line 81 of file RequestHandlerAdaptor.cpp.
References err_, proxygen::kErrorNone, proxygen::RequestHandler::onEOM(), and proxygen::ResponseHandler::upstream_.
|
overrideprivatevirtualnoexcept |
Can be called at any time before detachTransaction(). This callback implies that an error has occurred. To determine if ingress or egress is affected, check the direciont on the HTTPException. If the direction is INGRESS, it MAY still be possible to send egress.
Implements proxygen::HTTPTransactionHandler.
Definition at line 91 of file RequestHandlerAdaptor.cpp.
References proxygen::HTTPTransaction::canSendHeaders(), proxygen::ResponseBuilder::closeConnection(), err_, folly::pushmi::operators::error(), proxygen::HTTPException::INGRESS, proxygen::kErrorNone, proxygen::kErrorRead, proxygen::kErrorTimeout, proxygen::kErrorWrite, sendAbort(), proxygen::ResponseBuilder::sendWithEOM(), setError(), proxygen::ResponseBuilder::status(), and proxygen::ResponseHandler::txn_.
|
overrideprivatevirtualnoexcept |
Ask the handler to construct a handler for a ExTransaction associated with its transaction.
Reimplemented from proxygen::HTTPTransactionHandler.
Definition at line 135 of file RequestHandlerAdaptor.cpp.
References proxygen::RequestHandler::getExHandler(), handler(), RequestHandlerAdaptor(), and proxygen::ResponseHandler::upstream_.
|
overrideprivatevirtualnoexcept |
Called at most once per transaction. This is usually the first ingress callback. It is possible to get a read error before this however. If you had previously called pauseIngress(), this callback will be delayed until you call resumeIngress().
Implements proxygen::HTTPTransactionHandler.
Definition at line 41 of file RequestHandlerAdaptor.cpp.
References proxygen::RequestHandler::canHandleExpect(), proxygen::ResponseBuilder::closeConnection(), err_, proxygen::HTTP_HEADER_EXPECT, proxygen::kErrorNone, proxygen::kErrorUnsupportedExpectation, folly::gen::move, proxygen::RequestHandler::onRequest(), proxygen::ResponseBuilder::send(), proxygen::ResponseBuilder::sendWithEOM(), setError(), proxygen::ResponseBuilder::status(), and proxygen::ResponseHandler::upstream_.
|
overrideprivatevirtualnoexcept |
Can be called any number of times per transaction. If you had previously called pauseIngress(), this callback will be delayed until you call resumeIngress(). Trailers can be received once right before the EOM of a chunked HTTP/1.1 reponse or multiple times per transaction from SPDY and HTTP/2.0 HEADERS frames.
Implements proxygen::HTTPTransactionHandler.
Definition at line 76 of file RequestHandlerAdaptor.cpp.
|
overrideprivatevirtualnoexcept |
Can be called once per transaction. If you had previously called pauseIngress(), this callback will be delayed until you call resumeIngress(). After this callback is invoked, further data will be forwarded using the onBody() callback. Once the data transfer is completed (EOF recevied in case of CONNECT), onEOM() callback will be invoked.
Implements proxygen::HTTPTransactionHandler.
Definition at line 87 of file RequestHandlerAdaptor.cpp.
References proxygen::RequestHandler::onUpgrade(), and proxygen::ResponseHandler::upstream_.
|
overrideprivatevirtualnoexcept |
Implements proxygen::ResponseHandler.
Definition at line 169 of file RequestHandlerAdaptor.cpp.
References proxygen::HTTPTransaction::pauseIngress(), and proxygen::ResponseHandler::txn_.
|
overrideprivatevirtualnoexcept |
Implements proxygen::ResponseHandler.
Definition at line 165 of file RequestHandlerAdaptor.cpp.
References proxygen::HTTPTransaction::refreshTimeout(), and proxygen::ResponseHandler::txn_.
|
overrideprivatevirtualnoexcept |
Implements proxygen::ResponseHandler.
Definition at line 173 of file RequestHandlerAdaptor.cpp.
References proxygen::HTTPTransaction::resumeIngress(), and proxygen::ResponseHandler::txn_.
|
overrideprivatevirtualnoexcept |
Implements proxygen::ResponseHandler.
Definition at line 161 of file RequestHandlerAdaptor.cpp.
References proxygen::HTTPTransaction::sendAbort(), and proxygen::ResponseHandler::txn_.
Referenced by onError().
|
overrideprivatevirtualnoexcept |
Implements proxygen::ResponseHandler.
Definition at line 149 of file RequestHandlerAdaptor.cpp.
References b, folly::gen::move, proxygen::HTTPTransaction::sendBody(), and proxygen::ResponseHandler::txn_.
|
overrideprivatevirtualnoexcept |
Implements proxygen::ResponseHandler.
Definition at line 145 of file RequestHandlerAdaptor.cpp.
References proxygen::HTTPTransaction::sendChunkHeader(), and proxygen::ResponseHandler::txn_.
|
overrideprivatevirtualnoexcept |
Implements proxygen::ResponseHandler.
Definition at line 153 of file RequestHandlerAdaptor.cpp.
References proxygen::HTTPTransaction::sendChunkTerminator(), and proxygen::ResponseHandler::txn_.
|
overrideprivatevirtualnoexcept |
Implements proxygen::ResponseHandler.
Reimplemented in StubRequestHandlerAdaptor.
Definition at line 157 of file RequestHandlerAdaptor.cpp.
References proxygen::HTTPTransaction::sendEOM(), and proxygen::ResponseHandler::txn_.
|
overrideprivatevirtualnoexcept |
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.
Reimplemented in StubRequestHandlerAdaptor.
Definition at line 141 of file RequestHandlerAdaptor.cpp.
References proxygen::HTTPTransaction::sendHeaders(), and proxygen::ResponseHandler::txn_.
|
privatenoexcept |
Definition at line 207 of file RequestHandlerAdaptor.cpp.
References err_, proxygen::RequestHandler::onError(), and proxygen::ResponseHandler::upstream_.
Referenced by onError(), and onHeadersComplete().
|
overrideprivatevirtualnoexcept |
Called once per transaction. This notifies the handler of which transaction it should talk to and will receive callbacks from.
Implements proxygen::HTTPTransactionHandler.
Definition at line 24 of file RequestHandlerAdaptor.cpp.
References proxygen::RequestHandler::setResponseHandler(), proxygen::ResponseHandler::txn_, and proxygen::ResponseHandler::upstream_.
|
private |
Definition at line 77 of file RequestHandlerAdaptor.h.
Referenced by detachTransaction(), onEOM(), onError(), onHeadersComplete(), and setError().