Kea 2.5.8
isc::http::HttpListenerImpl Class Reference

Implementation of the HttpListener. More...

#include <listener_impl.h>

Public Member Functions

 HttpListenerImpl (const asiolink::IOServicePtr &io_service, const asiolink::IOAddress &server_address, const unsigned short server_port, const asiolink::TlsContextPtr &tls_context, const HttpResponseCreatorFactoryPtr &creator_factory, const long request_timeout, const long idle_timeout)
 Constructor.
 
virtual ~HttpListenerImpl ()
 Virtual destructor.
 
const asiolink::TCPEndpointgetEndpoint () const
 Returns reference to the current listener endpoint.
 
void start ()
 Starts accepting new connections.
 
void stop ()
 Stops all active connections and shuts down the service.
 

Protected Member Functions

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 HttpConnectionPtr createConnection (const HttpResponseCreatorPtr &response_creator, const HttpAcceptorCallback &callback)
 Creates an instance of the HttpConnection.
 

Protected Attributes

HttpAcceptorPtr acceptor_
 Acceptor instance.
 
HttpConnectionPool connections_
 Pool of active connections.
 
HttpResponseCreatorFactoryPtr creator_factory_
 Pointer to the HttpResponseCreatorFactory.
 
boost::scoped_ptr< asiolink::TCPEndpointendpoint_
 Pointer to the endpoint representing IP address and port on which the service is running.
 
long idle_timeout_
 Timeout after which idle persistent connection is closed by the server.
 
asiolink::IOServicePtr io_service_
 Pointer to the IO service.
 
long request_timeout_
 Timeout for HTTP Request Timeout desired.
 
asiolink::TlsContextPtr tls_context_
 TLS context.
 

Detailed Description

Implementation of the HttpListener.

Definition at line 22 of file listener_impl.h.

Constructor & Destructor Documentation

◆ HttpListenerImpl()

isc::http::HttpListenerImpl::HttpListenerImpl ( const asiolink::IOServicePtr io_service,
const asiolink::IOAddress server_address,
const unsigned short  server_port,
const asiolink::TlsContextPtr tls_context,
const HttpResponseCreatorFactoryPtr creator_factory,
const long  request_timeout,
const long  idle_timeout 
)

Constructor.

This constructor creates new server endpoint using the specified IP address and port. It also validates other specified parameters.

This constructor does not start accepting new connections! To start accepting connections run HttpListener::start.

Parameters
io_serviceIO service to be used by the listener.
server_addressAddress on which the HTTP service should run.
server_portPort number on which the HTTP service should run.
tls_contextTLS context.
creator_factoryPointer to the caller-defined HttpResponseCreatorFactory derivation which should be used to create HttpResponseCreator instances.
request_timeoutTimeout after which the HTTP Request Timeout is generated.
idle_timeoutTimeout after which an idle persistent HTTP connection is closed by the server.
Exceptions
HttpListenerErrorwhen any of the specified parameters is invalid.

Definition at line 19 of file listener_impl.cc.

References acceptor_, creator_factory_, endpoint_, idle_timeout_, isc_throw, and request_timeout_.

◆ ~HttpListenerImpl()

virtual isc::http::HttpListenerImpl::~HttpListenerImpl ( )
inlinevirtual

Virtual destructor.

Definition at line 56 of file listener_impl.h.

Member Function Documentation

◆ accept()

void isc::http::HttpListenerImpl::accept ( )
protected

Creates HttpConnection instance and adds it to the pool of active connections.

The next accepted connection will be handled by this instance.

Definition at line 94 of file listener_impl.cc.

References acceptHandler(), connections_, createConnection(), creator_factory_, and isc::http::HttpConnectionPool::start().

Referenced by acceptHandler(), and start().

+ Here is the call graph for this function:

◆ acceptHandler()

void isc::http::HttpListenerImpl::acceptHandler ( const boost::system::error_code &  ec)
protected

Callback invoked when the new connection is accepted.

It calls HttpListener::accept to create new HttpConnection instance.

Parameters
ecError code passed to the handler. This is currently ignored.

Definition at line 108 of file listener_impl.cc.

References accept().

Referenced by accept().

+ Here is the call graph for this function:

◆ createConnection()

HttpConnectionPtr isc::http::HttpListenerImpl::createConnection ( const HttpResponseCreatorPtr response_creator,
const HttpAcceptorCallback callback 
)
protectedvirtual

Creates an instance of the HttpConnection.

This method is virtual so as it can be overridden when customized connections are to be used, e.g. in case of unit testing.

Parameters
response_creatorPointer to the response creator object used to create HTTP response from the HTTP request received.
callbackCallback invoked when new connection is accepted.
Returns
Pointer to the created connection.

Definition at line 115 of file listener_impl.cc.

References acceptor_, connections_, idle_timeout_, io_service_, request_timeout_, and tls_context_.

Referenced by accept().

◆ getEndpoint()

const TCPEndpoint & isc::http::HttpListenerImpl::getEndpoint ( ) const

Returns reference to the current listener endpoint.

Definition at line 66 of file listener_impl.cc.

References endpoint_.

◆ start()

void isc::http::HttpListenerImpl::start ( )

Starts accepting new connections.

This method starts accepting and handling new HTTP connections on the IP address and port number specified in the constructor.

If the method is invoked successfully, it must not be invoked again until HttpListener::stop is called.

Exceptions
HttpListenerErrorif an error occurred.

Definition at line 71 of file listener_impl.cc.

References accept(), acceptor_, endpoint_, isc_throw, stop(), and isc::Exception::what().

+ Here is the call graph for this function:

◆ stop()

void isc::http::HttpListenerImpl::stop ( )

Stops all active connections and shuts down the service.

Definition at line 88 of file listener_impl.cc.

References acceptor_, connections_, and isc::http::HttpConnectionPool::stopAll().

Referenced by start().

+ Here is the call graph for this function:

Member Data Documentation

◆ acceptor_

HttpAcceptorPtr isc::http::HttpListenerImpl::acceptor_
protected

Acceptor instance.

Definition at line 112 of file listener_impl.h.

Referenced by HttpListenerImpl(), createConnection(), start(), and stop().

◆ connections_

HttpConnectionPool isc::http::HttpListenerImpl::connections_
protected

Pool of active connections.

Definition at line 119 of file listener_impl.h.

Referenced by accept(), createConnection(), and stop().

◆ creator_factory_

HttpResponseCreatorFactoryPtr isc::http::HttpListenerImpl::creator_factory_
protected

Pointer to the HttpResponseCreatorFactory.

Definition at line 122 of file listener_impl.h.

Referenced by HttpListenerImpl(), and accept().

◆ endpoint_

boost::scoped_ptr<asiolink::TCPEndpoint> isc::http::HttpListenerImpl::endpoint_
protected

Pointer to the endpoint representing IP address and port on which the service is running.

Definition at line 116 of file listener_impl.h.

Referenced by HttpListenerImpl(), getEndpoint(), and start().

◆ idle_timeout_

long isc::http::HttpListenerImpl::idle_timeout_
protected

Timeout after which idle persistent connection is closed by the server.

Definition at line 129 of file listener_impl.h.

Referenced by HttpListenerImpl(), and createConnection().

◆ io_service_

asiolink::IOServicePtr isc::http::HttpListenerImpl::io_service_
protected

Pointer to the IO service.

Definition at line 106 of file listener_impl.h.

Referenced by createConnection().

◆ request_timeout_

long isc::http::HttpListenerImpl::request_timeout_
protected

Timeout for HTTP Request Timeout desired.

Definition at line 125 of file listener_impl.h.

Referenced by HttpListenerImpl(), and createConnection().

◆ tls_context_

asiolink::TlsContextPtr isc::http::HttpListenerImpl::tls_context_
protected

TLS context.

Definition at line 109 of file listener_impl.h.

Referenced by createConnection().


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