proxygen
proxygen::SimpleController Class Reference

#include <SimpleController.h>

Inheritance diagram for proxygen::SimpleController:
proxygen::HTTPSessionController

Public Member Functions

 SimpleController (HTTPSessionAcceptor *acceptor)
 
HTTPTransactionHandlergetRequestHandler (HTTPTransaction &txn, HTTPMessage *msg) override
 
HTTPTransactionHandlergetParseErrorHandler (HTTPTransaction *txn, const HTTPException &error, const folly::SocketAddress &localAddress) override
 
HTTPTransactionHandlergetTransactionTimeoutHandler (HTTPTransaction *txn, const folly::SocketAddress &localAddress) override
 
void attachSession (HTTPSessionBase *) override
 
void detachSession (const HTTPSessionBase *) override
 
std::chrono::milliseconds getGracefulShutdownTimeout () const override
 
- Public Member Functions inherited from proxygen::HTTPSessionController
virtual ~HTTPSessionController ()
 
virtual void onSessionCodecChange (HTTPSessionBase *)
 
virtual std::chrono::milliseconds getSessionFlowControlTimeout () const
 
virtual const HeaderIndexingStrategygetHeaderIndexingStrategy () const
 

Protected Member Functions

HTTPTransactionHandlercreateErrorHandler (uint32_t statusCode, const std::string &statusMessage, const HTTPErrorPage *errorPage)
 

Protected Attributes

HTTPSessionAcceptor *const acceptor_ {nullptr}
 

Detailed Description

This simple controller provides some basic default behaviors. When errors occur, it will install an appropriate handler. Otherwise, it will install the acceptor's default handler.

Definition at line 25 of file SimpleController.h.

Constructor & Destructor Documentation

proxygen::SimpleController::SimpleController ( HTTPSessionAcceptor acceptor)
explicit

Definition at line 18 of file SimpleController.cpp.

19  : acceptor_(acceptor) {
20 }
HTTPSessionAcceptor *const acceptor_

Member Function Documentation

void proxygen::SimpleController::attachSession ( HTTPSessionBase session)
overridevirtual

Inform the controller it is associated with this particular session.

Implements proxygen::HTTPSessionController.

Definition at line 49 of file SimpleController.cpp.

49 {}
HTTPTransactionHandler * proxygen::SimpleController::createErrorHandler ( uint32_t  statusCode,
const std::string statusMessage,
const HTTPErrorPage errorPage 
)
protected

Definition at line 53 of file SimpleController.cpp.

Referenced by getParseErrorHandler(), and getTransactionTimeoutHandler().

56  {
57 
58  return new HTTPDirectResponseHandler(statusCode,
59  statusMessage,
60  errorPage);
61 }
spdy::GoawayStatusCode statusCode
Definition: SPDYCodec.cpp:110
void proxygen::SimpleController::detachSession ( const HTTPSessionBase session)
overridevirtual

Informed at the end when the given HTTPSession is going away.

Implements proxygen::HTTPSessionController.

Definition at line 51 of file SimpleController.cpp.

51 {}
std::chrono::milliseconds proxygen::SimpleController::getGracefulShutdownTimeout ( ) const
overridevirtual

Optionally allow the session to query custom graceful shutdown timeout.

Reimplemented from proxygen::HTTPSessionController.

Definition at line 63 of file SimpleController.cpp.

References acceptor_, and wangle::Acceptor::getGracefulShutdownTimeout().

63  {
65 }
std::chrono::milliseconds getGracefulShutdownTimeout() const
Definition: Acceptor.h:182
HTTPSessionAcceptor *const acceptor_
HTTPTransactionHandler * proxygen::SimpleController::getParseErrorHandler ( HTTPTransaction txn,
const HTTPException error,
const folly::SocketAddress localAddress 
)
overridevirtual

Will be invoked when HTTPSession is unable to parse a new request on the connection because of bad input.

error contains specific information about what went wrong

Implements proxygen::HTTPSessionController.

Definition at line 27 of file SimpleController.cpp.

References acceptor_, createErrorHandler(), proxygen::HTTPException::getCodecStatusCode(), proxygen::HTTPSessionAcceptor::getErrorPage(), proxygen::HTTPException::getHttpStatusCode(), proxygen::HTTPException::hasCodecStatusCode(), and proxygen::HTTPException::hasHttpStatusCode().

30  {
31 
32  if (error.hasCodecStatusCode()) {
33  return new CodecErrorResponseHandler(error.getCodecStatusCode());
34  }
35 
36  auto errorPage = acceptor_->getErrorPage(localAddress);
37  return createErrorHandler(error.hasHttpStatusCode() ?
38  error.getHttpStatusCode() : 400,
39  "Bad Request", errorPage);
40 }
HTTPTransactionHandler * createErrorHandler(uint32_t statusCode, const std::string &statusMessage, const HTTPErrorPage *errorPage)
requires And< SemiMovable< VN >... > &&SemiMovable< E > auto error(E e)
Definition: error.h:48
virtual const HTTPErrorPage * getErrorPage(const folly::SocketAddress &addr) const
HTTPSessionAcceptor *const acceptor_
HTTPTransactionHandler * proxygen::SimpleController::getRequestHandler ( HTTPTransaction txn,
HTTPMessage msg 
)
overridevirtual

Will be invoked whenever HTTPSession successfully parses a request

Implements proxygen::HTTPSessionController.

Definition at line 22 of file SimpleController.cpp.

References acceptor_, and proxygen::HTTPSessionAcceptor::newHandler().

23  {
24  return acceptor_->newHandler(txn, msg);
25 }
virtual HTTPTransaction::Handler * newHandler(HTTPTransaction &txn, HTTPMessage *msg) noexcept=0
HTTPSessionAcceptor *const acceptor_
HTTPTransactionHandler * proxygen::SimpleController::getTransactionTimeoutHandler ( HTTPTransaction txn,
const folly::SocketAddress localAddress 
)
overridevirtual

Will be invoked when HTTPSession times out parsing a new request.

Implements proxygen::HTTPSessionController.

Definition at line 42 of file SimpleController.cpp.

References acceptor_, createErrorHandler(), and proxygen::HTTPSessionAcceptor::getErrorPage().

43  {
44 
45  auto errorPage = acceptor_->getErrorPage(localAddress);
46  return createErrorHandler(408, "Client timeout", errorPage);
47 }
HTTPTransactionHandler * createErrorHandler(uint32_t statusCode, const std::string &statusMessage, const HTTPErrorPage *errorPage)
virtual const HTTPErrorPage * getErrorPage(const folly::SocketAddress &addr) const
HTTPSessionAcceptor *const acceptor_

Member Data Documentation

HTTPSessionAcceptor* const proxygen::SimpleController::acceptor_ {nullptr}
protected

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