2 * nghttp2 - HTTP/2 C Library
4 * Copyright (c) 2014 Tatsuhiro Tsujikawa
6 * Permission is hereby granted, free of charge, to any person obtaining
7 * a copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sublicense, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * The above copyright notice and this permission notice shall be
15 * included in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 // We wrote this code based on the original code which has the
31 // Copyright (c) 2003-2013 Christopher M. Kohlhoff (chris at kohlhoff dot com)
33 // Distributed under the Boost Software License, Version 1.0. (See accompanying
34 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
37 #ifndef HTTP_SERVER2_SERVER_HPP
38 #define HTTP_SERVER2_SERVER_HPP
40 #include "nghttp2_config.h"
45 #include <boost/noncopyable.hpp>
46 #include <boost/asio.hpp>
47 #include <boost/asio/ssl.hpp>
49 #include <nghttp2/asio_http2.h>
51 #include "asio_connection.h"
52 #include "asio_io_service_pool.h"
56 namespace asio_http2 {
60 /// The top-level class of the HTTP server.
61 class server : private boost::noncopyable {
63 /// Construct the server to listen on the specified TCP address and port, and
64 /// serve up files from the given directory.
65 explicit server(const std::string &address, uint16_t port,
66 std::size_t io_service_pool_size,
67 std::size_t thread_pool_size, request_cb cb,
68 std::unique_ptr<boost::asio::ssl::context> ssl_ctx,
71 /// Run the server's io_service loop.
75 /// Initiate an asynchronous accept operation.
80 /// The pool of io_service objects used to perform asynchronous operations.
81 io_service_pool io_service_pool_;
83 /// The signal_set is used to register for process termination notifications.
84 boost::asio::signal_set signals_;
86 boost::asio::deadline_timer tick_timer_;
88 /// Acceptor used to listen for incoming connections.
89 std::vector<boost::asio::ip::tcp::acceptor> acceptors_;
91 std::unique_ptr<boost::asio::ssl::context> ssl_ctx_;
93 request_cb request_cb_;
98 } // namespace asio_http2
100 } // namespace nghttp2
102 #endif // HTTP_SERVER2_SERVER_HPP