MySQL 26.7.0
Source Code Documentation
http::server::Server Class Reference

#include <server.h>

Inheritance diagram for http::server::Server:
[legend]

Classes

struct  RateLimitedLogState
 

Public Types

using native_handle_type = net::impl::socket::native_handle_type
 
using io_context = net::io_context
 
using socket = net::ip::tcp::socket
 
using Methods = base::method::Bitset
 
using IoThreads = std::list< IoThread >
 
using IoIterator = IoThreads::iterator
 

Public Member Functions

 Server (TlsServerContext *tls_context, IoThreads *threads, Bind *bind_raw, Bind *bind_ssl, uint64_t max_http_connections=kDefaultMaxHttpConnections, uint64_t max_request_body_size=kDefaultMaxRequestBodySize, uint64_t max_response_body_size=kDefaultMaxResponseBodySize, net::io_context *log_flush_context=nullptr)
 
void set_allowed_methods (const Methods &methods)
 
void set_request_handler (RequestHandlerInterface *handler)
 
void set_max_http_connections (std::optional< uint64_t > value)
 
uint64_t effective_max_http_connections () const
 
void set_max_request_body_size (std::optional< uint64_t > value)
 
uint64_t effective_max_request_body_size () const
 
void set_max_response_body_size (std::optional< uint64_t > value)
 
uint64_t effective_max_response_body_size () const
 
void clear_overrides ()
 
void start ()
 
void stop ()
 

Private Types

enum class  State { kInitializing , kRunning , kStopping , kStopped }
 

Private Member Functions

void on_new_ssl_connection (socket socket)
 
uint64_t max_request_body_size () const override
 
uint64_t max_response_body_size () const override
 
void log_max_request_body_size_rejection (uint64_t max_request_body_size, std::optional< uint64_t > content_length) override
 
void log_invalid_request_body_headers_rejection (std::string_view reason) override
 
void log_max_response_body_size_rejection (uint64_t max_response_body_size, uint64_t response_body_size) override
 
void on_connection_close (ConnectionTls *connection) override
 
void on_connection_io_error (ConnectionTls *connection, const std::error_code &ec) override
 
void on_new_connection (socket socket)
 
void on_connection_close (ConnectionRaw *connection) override
 
void on_connection_io_error (ConnectionRaw *connection, const std::error_code &ec) override
 
size_t disconnect_all ()
 
std::optional< uint64_t > reject_max_http_connections_limit () const
 
void log_max_http_connections_rejection (const uint64_t max_http_connections)
 
void schedule_suppressed_log_summary (RateLimitedLogState &state, const char *summary_message)
 
void cancel_suppressed_log_summary (RateLimitedLogState &state)
 
void flush_suppressed_log_summary (RateLimitedLogState &state, const char *summary_message)
 
void flush_all_suppressed_log_summaries ()
 
void cancel_all_suppressed_log_summaries ()
 
void start_accepting ()
 
socket socket_move_to_io_thread (socket socket)
 
IoThreadreturn_next_thread ()
 

Private Attributes

TlsServerContexttls_context_
 
std::list< IoThread > * threads_
 
IoIterator current_thread_
 
Bindbind_raw_
 
Bindbind_ssl_
 
net::io_contextlog_flush_context_
 
base::method::Bitset allowed_methods_
 
RequestHandlerInterfacehandler_ = nullptr
 
std::mutex mutex_connection_
 
std::vector< std::shared_ptr< ServerConnectionRaw > > connections_
 
std::vector< std::shared_ptr< ServerConnectionTls > > connections_ssl_
 
mysql_harness::utility::WaitableVariable< Statesync_state_
 
uint64_t configured_max_http_connections_ {kDefaultMaxHttpConnections}
 
uint64_t configured_max_request_body_size_ {kDefaultMaxRequestBodySize}
 
uint64_t configured_max_response_body_size_ {kDefaultMaxResponseBodySize}
 
std::atomic< bool > has_max_http_connections_override_
 
std::atomic< bool > has_max_request_body_size_override_
 
std::atomic< bool > has_max_response_body_size_override_
 
std::atomic< uint64_t > max_http_connections_override_
 
std::atomic< uint64_t > max_request_body_size_override_
 
std::atomic< uint64_t > max_response_body_size_override_
 
std::mutex mutex_limit_log_
 
RateLimitedLogState max_http_connections_reject_log_
 
RateLimitedLogState max_request_body_size_reject_log_
 
RateLimitedLogState invalid_request_body_headers_reject_log_
 
RateLimitedLogState max_response_body_size_reject_log_
 

Member Typedef Documentation

◆ io_context

using http::server::Server::io_context = net::io_context

◆ IoIterator

using http::server::Server::IoIterator = IoThreads::iterator

◆ IoThreads

using http::server::Server::IoThreads = std::list<IoThread>

◆ Methods

using http::server::Server::Methods = base::method::Bitset

◆ native_handle_type

using http::server::Server::native_handle_type = net::impl::socket::native_handle_type

◆ socket

using http::server::Server::socket = net::ip::tcp::socket

Member Enumeration Documentation

◆ State

enum class http::server::Server::State
strongprivate
Enumerator
kInitializing 
kRunning 
kStopping 
kStopped 

Constructor & Destructor Documentation

◆ Server()

http::server::Server::Server ( TlsServerContext tls_context,
IoThreads threads,
Bind bind_raw,
Bind bind_ssl,
uint64_t  max_http_connections = kDefaultMaxHttpConnections,
uint64_t  max_request_body_size = kDefaultMaxRequestBodySize,
uint64_t  max_response_body_size = kDefaultMaxResponseBodySize,
net::io_context log_flush_context = nullptr 
)

Member Function Documentation

◆ cancel_all_suppressed_log_summaries()

void http::server::Server::cancel_all_suppressed_log_summaries ( )
private

◆ cancel_suppressed_log_summary()

void http::server::Server::cancel_suppressed_log_summary ( RateLimitedLogState state)
private

◆ clear_overrides()

void http::server::Server::clear_overrides ( )

◆ disconnect_all()

size_t http::server::Server::disconnect_all ( )
private

◆ effective_max_http_connections()

uint64_t http::server::Server::effective_max_http_connections ( ) const

◆ effective_max_request_body_size()

uint64_t http::server::Server::effective_max_request_body_size ( ) const

◆ effective_max_response_body_size()

uint64_t http::server::Server::effective_max_response_body_size ( ) const

◆ flush_all_suppressed_log_summaries()

void http::server::Server::flush_all_suppressed_log_summaries ( )
private

◆ flush_suppressed_log_summary()

void http::server::Server::flush_suppressed_log_summary ( RateLimitedLogState state,
const char *  summary_message 
)
private

◆ log_invalid_request_body_headers_rejection()

void http::server::Server::log_invalid_request_body_headers_rejection ( std::string_view  reason)
overrideprivate

◆ log_max_http_connections_rejection()

void http::server::Server::log_max_http_connections_rejection ( const uint64_t  max_http_connections)
private

◆ log_max_request_body_size_rejection()

void http::server::Server::log_max_request_body_size_rejection ( uint64_t  max_request_body_size,
std::optional< uint64_t >  content_length 
)
overrideprivatevirtual

◆ log_max_response_body_size_rejection()

void http::server::Server::log_max_response_body_size_rejection ( uint64_t  max_response_body_size,
uint64_t  response_body_size 
)
overrideprivatevirtual

◆ max_request_body_size()

uint64_t http::server::Server::max_request_body_size ( ) const
inlineoverrideprivatevirtual

◆ max_response_body_size()

uint64_t http::server::Server::max_response_body_size ( ) const
inlineoverrideprivatevirtual

◆ on_connection_close() [1/2]

void http::server::Server::on_connection_close ( ConnectionRaw connection)
overrideprivate

◆ on_connection_close() [2/2]

void http::server::Server::on_connection_close ( ConnectionTls connection)
overrideprivate

◆ on_connection_io_error() [1/2]

void http::server::Server::on_connection_io_error ( ConnectionRaw connection,
const std::error_code &  ec 
)
overrideprivate

◆ on_connection_io_error() [2/2]

void http::server::Server::on_connection_io_error ( ConnectionTls connection,
const std::error_code &  ec 
)
overrideprivate

◆ on_new_connection()

void http::server::Server::on_new_connection ( socket  socket)
private

◆ on_new_ssl_connection()

void http::server::Server::on_new_ssl_connection ( socket  socket)
private

◆ reject_max_http_connections_limit()

std::optional< uint64_t > http::server::Server::reject_max_http_connections_limit ( ) const
private

◆ return_next_thread()

IoThread * http::server::Server::return_next_thread ( )
private

◆ schedule_suppressed_log_summary()

void http::server::Server::schedule_suppressed_log_summary ( RateLimitedLogState state,
const char *  summary_message 
)
private

◆ set_allowed_methods()

void http::server::Server::set_allowed_methods ( const Methods methods)

◆ set_max_http_connections()

void http::server::Server::set_max_http_connections ( std::optional< uint64_t >  value)

◆ set_max_request_body_size()

void http::server::Server::set_max_request_body_size ( std::optional< uint64_t >  value)

◆ set_max_response_body_size()

void http::server::Server::set_max_response_body_size ( std::optional< uint64_t >  value)

◆ set_request_handler()

void http::server::Server::set_request_handler ( RequestHandlerInterface handler)

◆ socket_move_to_io_thread()

Server::socket http::server::Server::socket_move_to_io_thread ( socket  socket)
private

◆ start()

void http::server::Server::start ( )

◆ start_accepting()

void http::server::Server::start_accepting ( )
private

◆ stop()

void http::server::Server::stop ( )

Member Data Documentation

◆ allowed_methods_

base::method::Bitset http::server::Server::allowed_methods_
private

◆ bind_raw_

Bind* http::server::Server::bind_raw_
private

◆ bind_ssl_

Bind* http::server::Server::bind_ssl_
private

◆ configured_max_http_connections_

uint64_t http::server::Server::configured_max_http_connections_ {kDefaultMaxHttpConnections}
private

◆ configured_max_request_body_size_

uint64_t http::server::Server::configured_max_request_body_size_ {kDefaultMaxRequestBodySize}
private

◆ configured_max_response_body_size_

uint64_t http::server::Server::configured_max_response_body_size_ {kDefaultMaxResponseBodySize}
private

◆ connections_

std::vector<std::shared_ptr<ServerConnectionRaw> > http::server::Server::connections_
private

◆ connections_ssl_

std::vector<std::shared_ptr<ServerConnectionTls> > http::server::Server::connections_ssl_
private

◆ current_thread_

IoIterator http::server::Server::current_thread_
private

◆ handler_

RequestHandlerInterface* http::server::Server::handler_ = nullptr
private

◆ has_max_http_connections_override_

std::atomic<bool> http::server::Server::has_max_http_connections_override_
private

◆ has_max_request_body_size_override_

std::atomic<bool> http::server::Server::has_max_request_body_size_override_
private

◆ has_max_response_body_size_override_

std::atomic<bool> http::server::Server::has_max_response_body_size_override_
private

◆ invalid_request_body_headers_reject_log_

RateLimitedLogState http::server::Server::invalid_request_body_headers_reject_log_
private

◆ log_flush_context_

net::io_context* http::server::Server::log_flush_context_
private

◆ max_http_connections_override_

std::atomic<uint64_t> http::server::Server::max_http_connections_override_
private

◆ max_http_connections_reject_log_

RateLimitedLogState http::server::Server::max_http_connections_reject_log_
private

◆ max_request_body_size_override_

std::atomic<uint64_t> http::server::Server::max_request_body_size_override_
private

◆ max_request_body_size_reject_log_

RateLimitedLogState http::server::Server::max_request_body_size_reject_log_
private

◆ max_response_body_size_override_

std::atomic<uint64_t> http::server::Server::max_response_body_size_override_
private

◆ max_response_body_size_reject_log_

RateLimitedLogState http::server::Server::max_response_body_size_reject_log_
private

◆ mutex_connection_

std::mutex http::server::Server::mutex_connection_
private

◆ mutex_limit_log_

std::mutex http::server::Server::mutex_limit_log_
private

◆ sync_state_

mysql_harness::utility::WaitableVariable<State> http::server::Server::sync_state_
private
Initial value:
{
State::kInitializing}

◆ threads_

std::list<IoThread>* http::server::Server::threads_
private

◆ tls_context_

TlsServerContext* http::server::Server::tls_context_
private

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