Kea  1.9.9-git
listener_impl.h
Go to the documentation of this file.
1 // Copyright (C) 2019-2021 Internet Systems Consortium, Inc. ("ISC")
2 //
3 // This Source Code Form is subject to the terms of the Mozilla Public
4 // License, v. 2.0. If a copy of the MPL was not distributed with this
5 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 
7 #ifndef HTTP_LISTENER_IMPL_H
8 #define HTTP_LISTENER_IMPL_H
9 
10 #include <asiolink/io_service.h>
11 #include <asiolink/io_address.h>
12 #include <asiolink/tcp_endpoint.h>
13 #include <http/connection.h>
14 #include <http/connection_pool.h>
16 #include <boost/scoped_ptr.hpp>
17 
18 namespace isc {
19 namespace http {
20 
23 public:
24 
48  const asiolink::IOAddress& server_address,
49  const unsigned short server_port,
50  const asiolink::TlsContextPtr& tls_context,
51  const HttpResponseCreatorFactoryPtr& creator_factory,
52  const long request_timeout,
53  const long idle_timeout);
54 
56  virtual ~HttpListenerImpl() {
57  }
58 
60  const asiolink::TCPEndpoint& getEndpoint() const;
61 
71  void start();
72 
74  void stop();
75 
76 protected:
77 
82  void accept();
83 
90  void acceptHandler(const boost::system::error_code& ec);
91 
102  virtual HttpConnectionPtr createConnection(const HttpResponseCreatorPtr& response_creator,
103  const HttpAcceptorCallback& callback);
104 
107 
110 
113 
116  boost::scoped_ptr<asiolink::TCPEndpoint> endpoint_;
117 
120 
123 
126 
130 };
131 
132 
133 } // end of namespace isc::http
134 } // end of namespace isc
135 
136 #endif // HTTP_LISTENER_IMPL_H
boost::shared_ptr< HttpResponseCreatorFactory > HttpResponseCreatorFactoryPtr
Pointer to the HttpResponseCreatorFactory.
asiolink::IOService & io_service_
Reference to the IO service.
Implementation of the HttpListener.
Definition: listener_impl.h:22
long idle_timeout_
Timeout after which idle persistent connection is closed by the server.
HttpResponseCreatorFactoryPtr creator_factory_
Pointer to the HttpResponseCreatorFactory.
boost::shared_ptr< HttpAcceptor > HttpAcceptorPtr
Type of shared pointer to TCP acceptors.
Definition: http_acceptor.h:31
virtual HttpConnectionPtr createConnection(const HttpResponseCreatorPtr &response_creator, const HttpAcceptorCallback &callback)
Creates an instance of the HttpConnection.
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.
Definition: http_acceptor.h:20
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.
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.
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.
boost::shared_ptr< HttpConnection > HttpConnectionPtr
Pointer to the HttpConnection.
Definition: connection.h:38
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.
virtual ~HttpListenerImpl()
Virtual destructor.
Definition: listener_impl.h:56
Pool of active HTTP connections.