proxygen
TestHandlerFactory::TestHandler Class Reference
Inheritance diagram for TestHandlerFactory::TestHandler:
proxygen::RequestHandler

Private Member Functions

void onRequest (std::unique_ptr< HTTPMessage >) noexceptoverride
 
void onBody (std::unique_ptr< folly::IOBuf >) noexceptoverride
 
void onUpgrade (UpgradeProtocol) noexceptoverride
 
void onEOM () noexceptoverride
 
void requestComplete () noexceptoverride
 
void onError (ProxygenError) noexceptoverride
 

Additional Inherited Members

- Public Member Functions inherited from proxygen::RequestHandler
virtual void setResponseHandler (ResponseHandler *handler) noexcept
 
virtual void onEgressPaused () noexcept
 
virtual void onEgressResumed () noexcept
 
virtual bool canHandleExpect () noexcept
 
virtual ExMessageHandlergetExHandler () noexcept
 
virtual ResponseHandlergetDownstream () noexcept
 
virtual ~RequestHandler ()
 
- Protected Attributes inherited from proxygen::RequestHandler
ResponseHandlerdownstream_ {nullptr}
 

Detailed Description

Definition at line 206 of file HTTPServerTest.cpp.

Member Function Documentation

void TestHandlerFactory::TestHandler::onBody ( std::unique_ptr< folly::IOBuf body)
inlineoverrideprivatevirtualnoexcept

Invoked when we get part of body for the request.

Implements proxygen::RequestHandler.

Definition at line 209 of file HTTPServerTest.cpp.

209 {}
void TestHandlerFactory::TestHandler::onEOM ( )
inlineoverrideprivatevirtualnoexcept

Invoked when we finish receiving the body.

Implements proxygen::RequestHandler.

Definition at line 213 of file HTTPServerTest.cpp.

References proxygen::ResponseBuilder::body(), folly::IOBuf::copyBuffer(), folly::ssl::OpenSSLCertUtils::getCommonName(), proxygen::ResponseBuilder::header(), proxygen::ResponseBuilder::sendWithEOM(), proxygen::ResponseBuilder::status(), string, and folly::Optional< Value >::value_or().

213  {
214  std::string certHeader("");
215  auto txn = CHECK_NOTNULL(downstream_->getTransaction());
216  auto& transport = txn->getTransport();
217  if (auto cert = transport.getUnderlyingTransport()->getPeerCert()) {
218  certHeader = OpenSSLCertUtils::getCommonName(*cert).value_or("");
219  }
221  .status(200, "OK")
222  .header("X-Client-CN", certHeader)
223  .body(IOBuf::copyBuffer("hello"))
224  .sendWithEOM();
225  }
ResponseBuilder & status(uint16_t code, const std::string &message)
HTTPTransaction * getTransaction() const noexcept
ResponseBuilder & body(std::unique_ptr< folly::IOBuf > bodyIn)
ResponseBuilder & header(const std::string &headerIn, const T &value)
std::unique_ptr< IOBuf > copyBuffer(const folly::IOBuf &buf)
const char * string
Definition: Conv.cpp:212
ResponseHandler * downstream_
void TestHandlerFactory::TestHandler::onError ( ProxygenError  err)
inlineoverrideprivatevirtualnoexcept

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 229 of file HTTPServerTest.cpp.

229 { delete this; }
void TestHandlerFactory::TestHandler::onRequest ( std::unique_ptr< HTTPMessage headers)
inlineoverrideprivatevirtualnoexcept

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 207 of file HTTPServerTest.cpp.

207  {
208  }
void TestHandlerFactory::TestHandler::onUpgrade ( UpgradeProtocol  prot)
inlineoverrideprivatevirtualnoexcept

Invoked when the session has been upgraded to a different protocol

Implements proxygen::RequestHandler.

Definition at line 210 of file HTTPServerTest.cpp.

210  {
211  }
void TestHandlerFactory::TestHandler::requestComplete ( )
inlineoverrideprivatevirtualnoexcept

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 227 of file HTTPServerTest.cpp.

227 { delete this; }

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