proxygen
HTTPSessionAcceptor.h
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  */
10 #pragma once
11 
19 
20 namespace proxygen {
21 
22 class HTTPSessionStats;
23 
29  public HTTPAcceptor,
31 public:
32  explicit HTTPSessionAcceptor(const AcceptorConfiguration& accConfig);
33  explicit HTTPSessionAcceptor(const AcceptorConfiguration& accConfig,
34  std::shared_ptr<HTTPCodecFactory> codecFactory);
35  ~HTTPSessionAcceptor() override;
36 
40  void setDefaultErrorPage(std::unique_ptr<HTTPErrorPage> generator) {
41  defaultErrorPage_ = std::move(generator);
42  }
43 
48  return defaultErrorPage_.get();
49  }
50 
54  void setDiagnosticErrorPage(std::unique_ptr<HTTPErrorPage> generator) {
55  diagnosticErrorPage_ = std::move(generator);
56  }
57 
62  return diagnosticErrorPage_.get();
63  }
64 
73  virtual const HTTPErrorPage* getErrorPage(
74  const folly::SocketAddress& addr) const;
75 
79  void setCodecFactory(std::shared_ptr<HTTPCodecFactory> codecFactory) {
80  codecFactory_ = codecFactory;
81  }
82 
86  std::shared_ptr<HTTPCodecFactory> getCodecFactory() {
87  return codecFactory_;
88  }
89 
98  HTTPTransaction& txn, HTTPMessage* msg) noexcept = 0;
99 
105  sessionInfoCb_ = cb;
106  }
107 
108  virtual bool getHttp2PrioritiesEnabled() {
110  }
111 
112 protected:
120  return &simpleController_;
121  }
122 
124 
126  return sessionInfoCb_ ? sessionInfoCb_ : this;
127  }
128 
129  // Acceptor methods
130  void onNewConnection(
132  const folly::SocketAddress* address,
133  const std::string& nextProtocol,
134  wangle::SecureTransportType secureTransportType,
135  const wangle::TransportInfo& tinfo) override;
136 
138  int fd) override {
140  new folly::AsyncSocket(base, fd));
141  }
142 
143  virtual size_t dropIdleConnections(size_t num);
144 
145  virtual void onSessionCreationError(ProxygenError /*error*/) {}
146 
147  private:
148  HTTPSessionAcceptor(const HTTPSessionAcceptor&) = delete;
150 
152  std::unique_ptr<HTTPErrorPage> defaultErrorPage_;
153 
155  std::unique_ptr<HTTPErrorPage> diagnosticErrorPage_;
156 
157  std::shared_ptr<HTTPCodecFactory> codecFactory_{};
158 
160 
162 
167 };
168 
169 } // proxygen
AcceptorConfiguration accConfig_
Definition: HTTPAcceptor.h:52
virtual void onSessionCreationError(ProxygenError)
std::default_random_engine generator
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
HTTPSessionAcceptor & operator=(const HTTPSessionAcceptor &)=delete
virtual HTTPTransaction::Handler * newHandler(HTTPTransaction &txn, HTTPMessage *msg) noexcept=0
requires E e noexcept(noexcept(s.error(std::move(e))))
HTTPSessionAcceptor(const AcceptorConfiguration &accConfig)
virtual size_t dropIdleConnections(size_t num)
void onNewConnection(folly::AsyncTransportWrapper::UniquePtr sock, const folly::SocketAddress *address, const std::string &nextProtocol, wangle::SecureTransportType secureTransportType, const wangle::TransportInfo &tinfo) override
void setSessionInfoCallback(HTTPSession::InfoCallback *cb)
std::unique_ptr< AsyncTransportWrapper, Destructor > UniquePtr
void setDefaultErrorPage(std::unique_ptr< HTTPErrorPage > generator)
virtual const HTTPErrorPage * getErrorPage(const folly::SocketAddress &addr) const
HTTPSessionStats * downstreamSessionStats_
void setCodecFactory(std::shared_ptr< HTTPCodecFactory > codecFactory)
std::shared_ptr< HTTPCodecFactory > getCodecFactory()
std::unique_ptr< HTTPErrorPage > diagnosticErrorPage_
virtual HTTPSessionController * getController()
HTTPSession::InfoCallback * getSessionInfoCallback()
const char * string
Definition: Conv.cpp:212
HTTPSession::InfoCallback * sessionInfoCb_
std::unique_ptr< HTTPErrorPage > defaultErrorPage_
static const folly::SocketAddress unknownSocketAddress_
folly::AsyncSocket::UniquePtr makeNewAsyncSocket(folly::EventBase *base, int fd) override
ThreadPoolListHook * addr
std::unique_ptr< AsyncSocket, Destructor > UniquePtr
Definition: AsyncSocket.h:83
const HTTPErrorPage * getDiagnosticErrorPage() const
void setDiagnosticErrorPage(std::unique_ptr< HTTPErrorPage > generator)
const HTTPErrorPage * getDefaultErrorPage() const
std::shared_ptr< HTTPCodecFactory > codecFactory_