proxygen
SimpleController.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015-present, Facebook, Inc.
3  * All rights reserved.
4  *
5  * This source code is licensed under the BSD-style license found in the
6  * LICENSE file in the root directory of this source tree. An additional grant
7  * of patent rights can be found in the PATENTS file in the same directory.
8  *
9  */
11 
15 
16 namespace proxygen {
17 
19  : acceptor_(acceptor) {
20 }
21 
23  HTTPTransaction& txn, HTTPMessage* msg) {
24  return acceptor_->newHandler(txn, msg);
25 }
26 
28  HTTPTransaction* /*txn*/,
29  const HTTPException& error,
30  const folly::SocketAddress& localAddress) {
31 
32  if (error.hasCodecStatusCode()) {
34  }
35 
36  auto errorPage = acceptor_->getErrorPage(localAddress);
37  return createErrorHandler(error.hasHttpStatusCode() ?
38  error.getHttpStatusCode() : 400,
39  "Bad Request", errorPage);
40 }
41 
43  HTTPTransaction* /*txn*/, const folly::SocketAddress& localAddress) {
44 
45  auto errorPage = acceptor_->getErrorPage(localAddress);
46  return createErrorHandler(408, "Client timeout", errorPage);
47 }
48 
50 
52 
55  const std::string& statusMessage,
56  const HTTPErrorPage* errorPage) {
57 
58  return new HTTPDirectResponseHandler(statusCode,
59  statusMessage,
60  errorPage);
61 }
62 
63 std::chrono::milliseconds SimpleController::getGracefulShutdownTimeout() const {
65 }
66 }
void attachSession(HTTPSessionBase *) override
spdy::GoawayStatusCode statusCode
Definition: SPDYCodec.cpp:110
bool hasCodecStatusCode() const
Definition: HTTPException.h:95
HTTPTransactionHandler * getParseErrorHandler(HTTPTransaction *txn, const HTTPException &error, const folly::SocketAddress &localAddress) override
bool hasHttpStatusCode() const
Definition: HTTPException.h:82
HTTPTransactionHandler * getRequestHandler(HTTPTransaction &txn, HTTPMessage *msg) override
HTTPTransactionHandler * createErrorHandler(uint32_t statusCode, const std::string &statusMessage, const HTTPErrorPage *errorPage)
virtual HTTPTransaction::Handler * newHandler(HTTPTransaction &txn, HTTPMessage *msg) noexcept=0
requires And< SemiMovable< VN >... > &&SemiMovable< E > auto error(E e)
Definition: error.h:48
std::chrono::milliseconds getGracefulShutdownTimeout() const
Definition: Acceptor.h:182
FizzServerAcceptor * acceptor_
ErrorCode getCodecStatusCode() const
virtual const HTTPErrorPage * getErrorPage(const folly::SocketAddress &addr) const
const char * string
Definition: Conv.cpp:212
HTTPSessionAcceptor *const acceptor_
void detachSession(const HTTPSessionBase *) override
HTTPTransactionHandler * getTransactionTimeoutHandler(HTTPTransaction *txn, const folly::SocketAddress &localAddress) override
uint32_t getHttpStatusCode() const
Definition: HTTPException.h:90
std::chrono::milliseconds getGracefulShutdownTimeout() const override
SimpleController(HTTPSessionAcceptor *acceptor)