diff --git a/boost/network/compat.hpp b/boost/network/compat.hpp new file mode 100644 index 000000000..a22b4a2a7 --- /dev/null +++ b/boost/network/compat.hpp @@ -0,0 +1,19 @@ +#ifndef BOOST_NETWORK_COMPAT_HPP__ +#define BOOST_NETWORK_COMPAT_HPP__ + +// Copyright 2019 (C) Enrico Detoma +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// These macros are used to solve a compatibility problem with Boost >= 1.70 +// where the deprecated method get_io_service() was removed. +#if BOOST_VERSION >= 107000 +#define CPP_NETLIB_ASIO_GET_IO_SERVICE(s) ((boost::asio::io_context&)(s).get_executor().context()) +#define CPP_NETLIB_ASIO_IO_SERVICE_CONTEXT boost::asio::io_context +#else +#define CPP_NETLIB_ASIO_GET_IO_SERVICE(s) ((s).get_io_service()) +#define CPP_NETLIB_ASIO_IO_SERVICE_CONTEXT boost::asio::io_service +#endif + +#endif // BOOST_NETWORK_COMPAT_HPP__ diff --git a/boost/network/protocol/http/client/connection/async_base.hpp b/boost/network/protocol/http/client/connection/async_base.hpp index ec1737828..455e7940f 100644 --- a/boost/network/protocol/http/client/connection/async_base.hpp +++ b/boost/network/protocol/http/client/connection/async_base.hpp @@ -16,6 +16,7 @@ #include #include #include +#include namespace boost { namespace network { @@ -59,7 +60,7 @@ struct async_connection_base { async_connection; typedef typename delegate_factory::type delegate_factory_type; auto delegate = delegate_factory_type::new_connection_delegate( - resolver.get_io_service(), https, always_verify_peer, + CPP_NETLIB_ASIO_GET_IO_SERVICE(resolver), https, always_verify_peer, certificate_filename, verify_path, certificate_file, private_key_file, ciphers, sni_hostname, ssl_options); auto temp = std::make_shared( diff --git a/boost/network/protocol/http/client/connection/async_normal.hpp b/boost/network/protocol/http/client/connection/async_normal.hpp index adae8edf0..107c8bf0e 100644 --- a/boost/network/protocol/http/client/connection/async_normal.hpp +++ b/boost/network/protocol/http/client/connection/async_normal.hpp @@ -32,6 +32,7 @@ #include #include #include +#include namespace boost { namespace network { @@ -154,12 +155,12 @@ struct http_async_connection connection_delegate_ptr delegate) : timeout_(timeout), remove_chunk_markers_(remove_chunk_markers), - timer_(resolver.get_io_service()), + timer_(CPP_NETLIB_ASIO_GET_IO_SERVICE(resolver)), is_timedout_(false), follow_redirect_(follow_redirect), resolver_(resolver), resolve_(std::move(resolve)), - request_strand_(resolver.get_io_service()), + request_strand_(CPP_NETLIB_ASIO_GET_IO_SERVICE(resolver)), delegate_(std::move(delegate)) {} // This is the main entry point for the connection/request pipeline. diff --git a/boost/network/protocol/http/client/connection/connection_delegate_factory.hpp b/boost/network/protocol/http/client/connection/connection_delegate_factory.hpp index fa419e1e6..8b86465c4 100644 --- a/boost/network/protocol/http/client/connection/connection_delegate_factory.hpp +++ b/boost/network/protocol/http/client/connection/connection_delegate_factory.hpp @@ -34,7 +34,8 @@ struct connection_delegate_factory { // This is the factory method that actually returns the delegate instance. // TODO(dberris): Support passing in proxy settings when crafting connections. static connection_delegate_ptr new_connection_delegate( - boost::asio::io_service& service, bool https, bool always_verify_peer, + CPP_NETLIB_ASIO_IO_SERVICE_CONTEXT& service, + bool https, bool always_verify_peer, optional certificate_filename, optional verify_path, optional certificate_file, optional private_key_file, optional ciphers, diff --git a/boost/network/protocol/http/client/connection/sync_normal.hpp b/boost/network/protocol/http/client/connection/sync_normal.hpp index 1f3775474..ec55e0e10 100644 --- a/boost/network/protocol/http/client/connection/sync_normal.hpp +++ b/boost/network/protocol/http/client/connection/sync_normal.hpp @@ -16,6 +16,7 @@ #include #include #include +#include namespace boost { namespace network { @@ -49,10 +50,10 @@ struct http_sync_connection int timeout) : connection_base(), timeout_(timeout), - timer_(resolver.get_io_service()), + timer_(CPP_NETLIB_ASIO_GET_IO_SERVICE(resolver)), resolver_(resolver), resolve_(std::move(resolve)), - socket_(resolver.get_io_service()) {} + socket_(CPP_NETLIB_ASIO_GET_IO_SERVICE(resolver)) {} void init_socket(string_type const& hostname, string_type const& port) { connection_base::init_socket(socket_, resolver_, hostname, port, resolve_); diff --git a/boost/network/protocol/http/client/connection/sync_ssl.hpp b/boost/network/protocol/http/client/connection/sync_ssl.hpp index 349449512..e25da99df 100644 --- a/boost/network/protocol/http/client/connection/sync_ssl.hpp +++ b/boost/network/protocol/http/client/connection/sync_ssl.hpp @@ -16,6 +16,7 @@ #include #include #include +#include namespace boost { namespace network { @@ -60,11 +61,11 @@ struct https_sync_connection long ssl_options = 0) : connection_base(), timeout_(timeout), - timer_(resolver.get_io_service()), + timer_(CPP_NETLIB_ASIO_GET_IO_SERVICE(resolver)), resolver_(resolver), resolve_(std::move(resolve)), - context_(resolver.get_io_service(), boost::asio::ssl::context::sslv23_client), - socket_(resolver.get_io_service(), context_) { + context_(CPP_NETLIB_ASIO_GET_IO_SERVICE(resolver), boost::asio::ssl::context::sslv23_client), + socket_(CPP_NETLIB_ASIO_GET_IO_SERVICE(resolver), context_) { if (ciphers) { ::SSL_CTX_set_cipher_list(context_.native_handle(), ciphers->c_str()); }