proxygen
proxygen::HTTPServerOptions Class Reference

#include <HTTPServerOptions.h>

Public Types

using NewConnectionFilter = folly::Function< void(const folly::AsyncTransportWrapper *, const folly::SocketAddress *, const std::string &, SecureTransportType, const wangle::TransportInfo &) const >
 

Public Member Functions

void useExistingSocket (folly::AsyncServerSocket::UniquePtr socket)
 
void useExistingSocket (int socketFd)
 
void useExistingSockets (const std::vector< int > &socketFds)
 

Public Attributes

size_t threads = 1
 
std::vector< std::unique_ptr< RequestHandlerFactory > > handlerFactories
 
std::chrono::milliseconds idleTimeout {60000}
 
uint32_t listenBacklog {1024}
 
bool h2cEnabled {false}
 
std::vector< int > shutdownOn {}
 
bool supportsConnect {false}
 
size_t initialReceiveWindow {65536}
 
size_t receiveStreamWindowSize {65536}
 
size_t receiveSessionWindowSize {65536}
 
uint32_t maxConcurrentIncomingStreams {100}
 
bool enableContentCompression {false}
 
uint64_t contentCompressionMinimumSize {1000}
 
int contentCompressionLevel {-1}
 
bool enableExHeaders {false}
 
std::set< std::stringcontentCompressionTypes
 
std::vector< folly::AsyncServerSocket::UniquePtrpreboundSockets_
 
NewConnectionFilter newConnectionFilter
 

Detailed Description

Configuration options for HTTPServer

XXX: Provide a helper that can convert thrift/json to this config directly. We keep this object type-safe.

Definition at line 27 of file HTTPServerOptions.h.

Member Typedef Documentation

Type of function to run inside onNewConnection() of acceptors. If the function throws, the socket will be closed immediately. Useful for validating client cert before processing the request.

Definition at line 39 of file HTTPServerOptions.h.

Member Function Documentation

void proxygen::HTTPServerOptions::useExistingSocket ( folly::AsyncServerSocket::UniquePtr  socket)
inline

Bind to existing file descriptor(s). AsyncServerSocket can handle multiple fds and they can be provided as a vector here.

Definition at line 166 of file HTTPServerOptions.h.

References folly::gen::move.

Referenced by TEST(), and useExistingSockets().

166  {
167  preboundSockets_.push_back(std::move(socket));
168  }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
NetworkSocket socket(int af, int type, int protocol)
Definition: NetOps.cpp:412
std::vector< folly::AsyncServerSocket::UniquePtr > preboundSockets_
void proxygen::HTTPServerOptions::useExistingSocket ( int  socketFd)
inline

Definition at line 170 of file HTTPServerOptions.h.

References useExistingSockets().

170  {
171  useExistingSockets({socketFd});
172  }
void useExistingSockets(const std::vector< int > &socketFds)
void proxygen::HTTPServerOptions::useExistingSockets ( const std::vector< int > &  socketFds)
inline

Definition at line 174 of file HTTPServerOptions.h.

References folly::gen::move, folly::netops::socket(), and useExistingSocket().

Referenced by TEST(), and useExistingSocket().

174  {
176 
177  socket->useExistingSockets(socketFds);
179  }
void useExistingSocket(folly::AsyncServerSocket::UniquePtr socket)
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
NetworkSocket socket(int af, int type, int protocol)
Definition: NetOps.cpp:412
std::unique_ptr< AsyncServerSocket, Destructor > UniquePtr

Member Data Documentation

int proxygen::HTTPServerOptions::contentCompressionLevel {-1}

Zlib compression level, valid values are -1(Default) to 9(Slower). 4 or 6 are a good balance between compression level and cpu usage.

Definition at line 131 of file HTTPServerOptions.h.

uint64_t proxygen::HTTPServerOptions::contentCompressionMinimumSize {1000}

Requests smaller than the specified number of bytes will not be compressed

Definition at line 125 of file HTTPServerOptions.h.

std::set<std::string> proxygen::HTTPServerOptions::contentCompressionTypes
Initial value:
= {
"application/javascript",
"application/json",
"application/x-javascript",
"application/xhtml+xml",
"application/xml",
"application/xml+rss",
"text/css",
"text/html",
"text/javascript",
"text/plain",
"text/xml",
}

Content types to compress, all entries as lowercase

Definition at line 141 of file HTTPServerOptions.h.

bool proxygen::HTTPServerOptions::enableContentCompression {false}

Set to true to enable gzip content compression. Currently false for backwards compatibility.

Definition at line 120 of file HTTPServerOptions.h.

Referenced by main().

bool proxygen::HTTPServerOptions::enableExHeaders {false}

Enable support for pub-sub extension.

Definition at line 136 of file HTTPServerOptions.h.

Referenced by proxygen::HTTPServerAcceptor::makeConfig().

bool proxygen::HTTPServerOptions::h2cEnabled {false}

Enable cleartext upgrades to HTTP/2

Definition at line 87 of file HTTPServerOptions.h.

Referenced by main(), and proxygen::HTTPServerAcceptor::makeConfig().

std::vector<std::unique_ptr<RequestHandlerFactory> > proxygen::HTTPServerOptions::handlerFactories

Chain of RequestHandlerFactory that are used to create RequestHandler which handles requests.

You can do something like -

handlerFactories = RequestHandlerChain() .addThen<StatsFilter>() .addThen<TraceFilter>() .addThen<AccessLogFilter>() .addThen<AppSpecificHandler>() .build();

Definition at line 65 of file HTTPServerOptions.h.

Referenced by ScopedServerTest::createDefaultOpts(), ConnectionFilterTest::createDefaultOpts(), main(), proxygen::HTTPServerAcceptor::make(), proxygen::ScopedHTTPServer::start< std::unique_ptr< RequestHandlerFactory > >(), setupServer(), and TEST().

std::chrono::milliseconds proxygen::HTTPServerOptions::idleTimeout {60000}

This idle timeout serves two purposes -

  1. How long to keep idle connections around before throwing them away.
  2. If it takes client more than this time to send request, we fail the request.

XXX: Maybe have separate time limit for both?

Definition at line 77 of file HTTPServerOptions.h.

Referenced by main(), and proxygen::HTTPServerAcceptor::makeConfig().

size_t proxygen::HTTPServerOptions::initialReceiveWindow {65536}

Flow control configuration for the acceptor

Definition at line 106 of file HTTPServerOptions.h.

Referenced by proxygen::HTTPServerAcceptor::makeConfig().

uint32_t proxygen::HTTPServerOptions::listenBacklog {1024}

TCP server socket backlog to start with.

Definition at line 82 of file HTTPServerOptions.h.

Referenced by proxygen::HTTPServerAcceptor::makeConfig().

uint32_t proxygen::HTTPServerOptions::maxConcurrentIncomingStreams {100}

The maximum number of transactions the remote could initiate per connection on protocols that allow multiplexing.

Definition at line 114 of file HTTPServerOptions.h.

Referenced by proxygen::HTTPServerAcceptor::makeConfig().

NewConnectionFilter proxygen::HTTPServerOptions::newConnectionFilter

Invoked after a new connection is created. Drop connection if the function throws any exception.

Definition at line 185 of file HTTPServerOptions.h.

Referenced by ConnectionFilterTest::createDefaultOpts(), and proxygen::HTTPServerAcceptor::onNewConnection().

std::vector<folly::AsyncServerSocket::UniquePtr> proxygen::HTTPServerOptions::preboundSockets_

This holds sockets already bound to addresses that the server will listen on and will be empty once the server starts.

Definition at line 159 of file HTTPServerOptions.h.

size_t proxygen::HTTPServerOptions::receiveSessionWindowSize {65536}

Definition at line 108 of file HTTPServerOptions.h.

Referenced by proxygen::HTTPServerAcceptor::makeConfig().

size_t proxygen::HTTPServerOptions::receiveStreamWindowSize {65536}

Definition at line 107 of file HTTPServerOptions.h.

Referenced by proxygen::HTTPServerAcceptor::makeConfig().

std::vector<int> proxygen::HTTPServerOptions::shutdownOn {}

Signals on which to shutdown the server. Mostly you will want {SIGINT, SIGTERM}. Note, if you have multiple deamons running or you want to have a separate signal handler, leave this empty and handle signals yourself.

Definition at line 95 of file HTTPServerOptions.h.

Referenced by main().

bool proxygen::HTTPServerOptions::supportsConnect {false}

Set to true if you want to support CONNECT request. Most likely you don't want that.

Definition at line 101 of file HTTPServerOptions.h.

Referenced by main().

size_t proxygen::HTTPServerOptions::threads = 1

Number of threads to start to handle requests. Note that this excludes the thread you call HTTPServer.start() in.

XXX: Put some perf numbers to help user decide how many threads to create. XXX: Maybe support not creating any more worker threads and doing all the work in same thread when threads == 0.

Definition at line 50 of file HTTPServerOptions.h.

Referenced by ScopedServerTest::createDefaultOpts(), ConnectionFilterTest::createDefaultOpts(), main(), proxygen::ScopedHTTPServer::start< std::unique_ptr< RequestHandlerFactory > >(), setupServer(), and TEST().


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