Kea
1.9.9-git
|
Implementation of the HttpListener. More...
#include <listener_impl.h>
Public Member Functions | |
HttpListenerImpl (asiolink::IOService &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. More... | |
virtual | ~HttpListenerImpl () |
Virtual destructor. More... | |
const asiolink::TCPEndpoint & | getEndpoint () const |
Returns reference to the current listener endpoint. More... | |
void | start () |
Starts accepting new connections. More... | |
void | stop () |
Stops all active connections and shuts down the service. More... | |
Protected Member Functions | |
void | accept () |
Creates HttpConnection instance and adds it to the pool of active connections. More... | |
void | acceptHandler (const boost::system::error_code &ec) |
Callback invoked when the new connection is accepted. More... | |
virtual HttpConnectionPtr | createConnection (const HttpResponseCreatorPtr &response_creator, const HttpAcceptorCallback &callback) |
Creates an instance of the HttpConnection . More... | |
Protected Attributes | |
HttpAcceptorPtr | acceptor_ |
Acceptor instance. More... | |
HttpConnectionPool | connections_ |
Pool of active connections. More... | |
HttpResponseCreatorFactoryPtr | creator_factory_ |
Pointer to the HttpResponseCreatorFactory. More... | |
boost::scoped_ptr< asiolink::TCPEndpoint > | endpoint_ |
Pointer to the endpoint representing IP address and port on which the service is running. More... | |
long | idle_timeout_ |
Timeout after which idle persistent connection is closed by the server. More... | |
asiolink::IOService & | io_service_ |
Reference to the IO service. More... | |
long | request_timeout_ |
Timeout for HTTP Request Timeout desired. More... | |
asiolink::TlsContextPtr | tls_context_ |
TLS context. More... | |
Implementation of the HttpListener.
Definition at line 22 of file listener_impl.h.
isc::http::HttpListenerImpl::HttpListenerImpl | ( | asiolink::IOService & | 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.
io_service | IO service to be used by the listener. |
server_address | Address on which the HTTP service should run. |
server_port | Port number on which the HTTP service should run. |
tls_context | TLS context. |
creator_factory | Pointer to the caller-defined HttpResponseCreatorFactory derivation which should be used to create HttpResponseCreator instances. |
request_timeout | Timeout after which the HTTP Request Timeout is generated. |
idle_timeout | Timeout after which an idle persistent HTTP connection is closed by the server. |
HttpListenerError | when 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_.
|
inlinevirtual |
Virtual destructor.
Definition at line 56 of file listener_impl.h.
|
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().
|
protected |
Callback invoked when the new connection is accepted.
It calls HttpListener::accept
to create new HttpConnection
instance.
ec | Error code passed to the handler. This is currently ignored. |
Definition at line 108 of file listener_impl.cc.
References accept().
Referenced by accept().
|
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.
response_creator | Pointer to the response creator object used to create HTTP response from the HTTP request received. |
callback | Callback invoked when new connection is accepted. |
Definition at line 115 of file listener_impl.cc.
References acceptor_, connections_, idle_timeout_, io_service_, request_timeout_, and tls_context_.
Referenced by accept().
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_.
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.
HttpListenerError | if an error occurred. |
Definition at line 71 of file listener_impl.cc.
References accept(), acceptor_, endpoint_, isc_throw, stop(), and isc::Exception::what().
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().
|
protected |
Acceptor instance.
Definition at line 112 of file listener_impl.h.
Referenced by createConnection(), HttpListenerImpl(), start(), and stop().
|
protected |
Pool of active connections.
Definition at line 119 of file listener_impl.h.
Referenced by accept(), createConnection(), and stop().
|
protected |
Pointer to the HttpResponseCreatorFactory.
Definition at line 122 of file listener_impl.h.
Referenced by accept(), and HttpListenerImpl().
|
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 getEndpoint(), HttpListenerImpl(), and start().
|
protected |
Timeout after which idle persistent connection is closed by the server.
Definition at line 129 of file listener_impl.h.
Referenced by createConnection(), and HttpListenerImpl().
|
protected |
Reference to the IO service.
Definition at line 106 of file listener_impl.h.
Referenced by createConnection().
|
protected |
Timeout for HTTP Request Timeout desired.
Definition at line 125 of file listener_impl.h.
Referenced by createConnection(), and HttpListenerImpl().
|
protected |