14 namespace ph = std::placeholders;
19 HttpListenerImpl::HttpListenerImpl(
IOService& io_service,
21 const unsigned short server_port,
24 const long request_timeout,
25 const long idle_timeout)
26 : io_service_(io_service), tls_context_(tls_context), acceptor_(),
27 endpoint_(), connections_(),
28 creator_factory_(creator_factory),
29 request_timeout_(request_timeout), idle_timeout_(idle_timeout) {
43 << server_address <<
":" << server_port);
78 }
catch (
const boost::system::system_error& ex) {
81 "listening to the incoming HTTP requests: " << ex.
what());
boost::shared_ptr< HttpResponseCreatorFactory > HttpResponseCreatorFactoryPtr
Pointer to the HttpResponseCreatorFactory.
asiolink::IOService & io_service_
Reference to the IO service.
void start(const HttpConnectionPtr &connection)
Start new connection.
Accepts and handles a single HTTP connection.
asiolink::TCPAcceptor< HttpAcceptorCallback > HttpAcceptor
Type of the TCP acceptor used in this library.
long idle_timeout_
Timeout after which idle persistent connection is closed by the server.
HttpResponseCreatorFactoryPtr creator_factory_
Pointer to the HttpResponseCreatorFactory.
virtual HttpConnectionPtr createConnection(const HttpResponseCreatorPtr &response_creator, const HttpAcceptorCallback &callback)
Creates an instance of the HttpConnection.
A generic error raised by the HttpListener class.
void start()
Starts accepting new connections.
const asiolink::TCPEndpoint & getEndpoint() const
Returns reference to the current listener endpoint.
std::function< void(const boost::system::error_code &)> HttpAcceptorCallback
Type of the callback for the TCP acceptor used in this library.
The IOService class is a wrapper for the ASIO io_service class.
boost::shared_ptr< TlsContext > TlsContextPtr
The type of shared pointers to TlsContext objects.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
The TCPEndpoint class is a concrete derived class of IOEndpoint that represents an endpoint of a TCP ...
long request_timeout_
Timeout for HTTP Request Timeout desired.
void accept()
Creates HttpConnection instance and adds it to the pool of active connections.
void acceptHandler(const boost::system::error_code &ec)
Callback invoked when the new connection is accepted.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
asiolink::TLSAcceptor< HttpAcceptorCallback > HttpsAcceptor
Type of the TLS acceptor used in this library.
boost::shared_ptr< HttpResponseCreator > HttpResponseCreatorPtr
Pointer to the HttpResponseCreator object.
Defines the logger used by the top-level component of kea-dhcp-ddns.
HttpConnectionPool connections_
Pool of active connections.
boost::asio::socket_base::reuse_address ReuseAddress
Represents SO_REUSEADDR socket option.
void stopAll()
Stops all connections and removes them from the pool.
boost::shared_ptr< HttpConnection > HttpConnectionPtr
Pointer to the HttpConnection.
void stop()
Stops all active connections and shuts down the service.
boost::scoped_ptr< asiolink::TCPEndpoint > endpoint_
Pointer to the endpoint representing IP address and port on which the service is running.
HttpAcceptorPtr acceptor_
Acceptor instance.
asiolink::TlsContextPtr tls_context_
TLS context.
The IOAddress class represents an IP addresses (version agnostic)