Kea  1.9.9-git
listener.h
Go to the documentation of this file.
1 // Copyright (C) 2017-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_H
8 #define HTTP_LISTENER_H
9 
10 #include <asiolink/io_address.h>
11 #include <asiolink/io_service.h>
12 #include <asiolink/crypto_tls.h>
13 #include <exceptions/exceptions.h>
15 #include <boost/shared_ptr.hpp>
16 #include <cstdint>
17 
18 namespace isc {
19 namespace http {
20 
22 class HttpListenerError : public Exception {
23 public:
24  HttpListenerError(const char* file, size_t line, const char* what) :
25  isc::Exception(file, line, what) { };
26 };
27 
29 class HttpListenerImpl;
30 
52 class HttpListener {
53 public:
54 
56  struct RequestTimeout {
60  explicit RequestTimeout(long value)
61  : value_(value) {
62  }
63  long value_;
64  };
65 
67  struct IdleTimeout {
71  explicit IdleTimeout(long value)
72  : value_(value) {
73  }
74  long value_;
75  };
76 
100  const asiolink::IOAddress& server_address,
101  const unsigned short server_port,
102  const asiolink::TlsContextPtr& tls_context,
103  const HttpResponseCreatorFactoryPtr& creator_factory,
104  const RequestTimeout& request_timeout,
105  const IdleTimeout& idle_timeout);
106 
110  ~HttpListener();
111 
114 
116  uint16_t getLocalPort() const;
117 
127  void start();
128 
130  void stop();
131 
132 protected:
133 
135  boost::shared_ptr<HttpListenerImpl> impl_;
136 };
137 
139 typedef boost::shared_ptr<HttpListener> HttpListenerPtr;
140 
142 typedef boost::shared_ptr<const HttpListener> ConstHttpListenerPtr;
143 
144 } // end of namespace isc::http
145 } // end of namespace isc
146 
147 #endif
RequestTimeout(long value)
Constructor.
Definition: listener.h:60
~HttpListener()
Destructor.
Definition: listener.cc:31
boost::shared_ptr< HttpResponseCreatorFactory > HttpResponseCreatorFactoryPtr
Pointer to the HttpResponseCreatorFactory.
IdleTimeout(long value)
Constructor.
Definition: listener.h:71
boost::shared_ptr< const HttpListener > ConstHttpListenerPtr
Pointer to the const HttpListener.
Definition: listener.h:142
void start()
Starts accepting new connections.
Definition: listener.cc:46
A generic error raised by the HttpListener class.
Definition: listener.h:22
boost::shared_ptr< HttpListenerImpl > impl_
Pointer to the implementation of the HttpListener.
Definition: listener.h:135
HttpListenerError(const char *file, size_t line, const char *what)
Definition: listener.h:24
HTTP listener.
Definition: listener.h:52
asiolink::IOAddress getLocalAddress() const
Returns local address on which server is listening.
Definition: listener.cc:36
Idle connection timeout.
Definition: listener.h:67
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
This is a base class for exceptions thrown from the DNS library module.
Defines the logger used by the top-level component of kea-dhcp-ddns.
TLS API.
HttpListener(asiolink::IOService &io_service, const asiolink::IOAddress &server_address, const unsigned short server_port, const asiolink::TlsContextPtr &tls_context, const HttpResponseCreatorFactoryPtr &creator_factory, const RequestTimeout &request_timeout, const IdleTimeout &idle_timeout)
Constructor.
Definition: listener.cc:18
void stop()
Stops all active connections and shuts down the service.
Definition: listener.cc:51
uint16_t getLocalPort() const
Returns local port on which server is listening.
Definition: listener.cc:41
long value_
Connection idle timeout value specified.
Definition: listener.h:74
boost::shared_ptr< HttpListener > HttpListenerPtr
Pointer to the HttpListener.
Definition: listener.h:139
long value_
Request timeout value specified.
Definition: listener.h:63
HTTP request timeout value.
Definition: listener.h:56