From 5b5d5d78525af93e9058b27cd75a13233b431dbf Mon Sep 17 00:00:00 2001 From: Glyn Matthews Date: Tue, 19 Apr 2016 19:44:16 +0200 Subject: [PATCH] Found every instance of the 'asio' namespace, and qualified them unambiguously. --- .../protocol/http/client/async_impl.hpp | 14 +++---- .../http/client/connection/async_normal.hpp | 42 +++++++++---------- .../connection/async_protocol_handler.hpp | 10 ++--- .../client/connection/connection_delegate.hpp | 6 +-- .../connection_delegate_factory.hpp | 2 +- .../client/connection/normal_delegate.hpp | 12 +++--- .../client/connection/normal_delegate.ipp | 16 +++---- .../http/client/connection/ssl_delegate.hpp | 16 +++---- .../http/client/connection/ssl_delegate.ipp | 36 ++++++++-------- .../http/client/connection/sync_base.hpp | 40 +++++++++--------- .../http/client/connection/sync_normal.hpp | 14 +++---- .../http/client/connection/sync_ssl.hpp | 30 ++++++------- .../network/protocol/http/client/options.hpp | 8 ++-- boost/network/protocol/http/client/pimpl.hpp | 2 +- .../protocol/http/client/sync_impl.hpp | 8 ++-- boost/network/protocol/http/impl/response.ipp | 16 +++---- .../protocol/http/policies/async_resolver.hpp | 4 +- .../http/policies/pooled_connection.hpp | 4 +- .../http/policies/simple_connection.hpp | 2 +- .../protocol/http/server/async_connection.hpp | 38 ++++++++--------- .../protocol/http/server/async_server.hpp | 6 +-- .../network/protocol/http/server/options.hpp | 30 ++++++------- .../http/server/socket_options_base.hpp | 18 ++++---- .../protocol/http/server/storage_base.hpp | 6 +-- .../network/protocol/http/traits/resolver.hpp | 4 +- boost/network/protocol/stream_handler.hpp | 12 +++--- boost/network/uri/builder.hpp | 12 +++--- boost/network/utils/thread_pool.hpp | 8 ++-- 28 files changed, 208 insertions(+), 208 deletions(-) diff --git a/boost/network/protocol/http/client/async_impl.hpp b/boost/network/protocol/http/client/async_impl.hpp index bb4eab191..fb1dc5079 100644 --- a/boost/network/protocol/http/client/async_impl.hpp +++ b/boost/network/protocol/http/client/async_impl.hpp @@ -39,7 +39,7 @@ struct async_client async_client(bool cache_resolved, bool follow_redirect, bool always_verify_peer, int timeout, - std::shared_ptr service, + std::shared_ptr<::asio::io_service> service, optional certificate_filename, optional verify_path, optional certificate_file, @@ -48,10 +48,10 @@ struct async_client optional sni_hostname, long ssl_options) : connection_base(cache_resolved, follow_redirect, timeout), service_ptr(service.get() ? service - : std::make_shared()), + : std::make_shared<::asio::io_service>()), service_(*service_ptr), resolver_(service_), - sentinel_(new asio::io_service::work(service_)), + sentinel_(new ::asio::io_service::work(service_)), certificate_filename_(std::move(certificate_filename)), verify_path_(std::move(verify_path)), certificate_file_(std::move(certificate_file)), @@ -61,7 +61,7 @@ struct async_client ssl_options_(ssl_options), always_verify_peer_(always_verify_peer) { connection_base::resolver_strand_.reset( - new asio::io_service::strand(service_)); + new ::asio::io_service::strand(service_)); if (!service) lifetime_thread_.reset(new std::thread([this]() { service_.run(); })); } @@ -89,10 +89,10 @@ struct async_client generator); } - std::shared_ptr service_ptr; - asio::io_service& service_; + std::shared_ptr<::asio::io_service> service_ptr; + ::asio::io_service& service_; resolver_type resolver_; - std::shared_ptr sentinel_; + std::shared_ptr<::asio::io_service::work> sentinel_; std::shared_ptr lifetime_thread_; optional certificate_filename_; optional verify_path_; diff --git a/boost/network/protocol/http/client/connection/async_normal.hpp b/boost/network/protocol/http/client/connection/async_normal.hpp index 1604a727e..35c12b365 100644 --- a/boost/network/protocol/http/client/connection/async_normal.hpp +++ b/boost/network/protocol/http/client/connection/async_normal.hpp @@ -40,7 +40,7 @@ namespace impl { template struct async_connection_base; -namespace placeholders = asio::placeholders; +namespace placeholders = ::asio::placeholders; template struct http_async_connection @@ -145,7 +145,7 @@ struct http_async_connection // Here we deal with the case that there was an error encountered and // that there's still more endpoints to try connecting to. resolver_iterator iter = boost::begin(endpoint_range); - asio::ip::tcp::endpoint endpoint(iter->endpoint().address(), port); + ::asio::ip::tcp::endpoint endpoint(iter->endpoint().address(), port); auto self = this->shared_from_this(); delegate_->connect( endpoint, host, source_port, @@ -155,7 +155,7 @@ struct http_async_connection generator, std::make_pair(++iter_copy, resolver_iterator()), ec); })); } else { - set_errors(ec ? ec : asio::error::host_not_found); + set_errors(ec ? ec : ::asio::error::host_not_found); boost::iterator_range range; if (callback) callback(range, ec); } @@ -168,7 +168,7 @@ struct http_async_connection resolver_iterator_pair endpoint_range, std::error_code const& ec) { if (is_timedout_) { - set_errors(asio::error::timed_out); + set_errors(::asio::error::timed_out); } else if (!ec) { BOOST_ASSERT(delegate_.get() != 0); auto self = this->shared_from_this(); @@ -182,7 +182,7 @@ struct http_async_connection } else { if (!boost::empty(endpoint_range)) { resolver_iterator iter = boost::begin(endpoint_range); - asio::ip::tcp::endpoint endpoint(iter->endpoint().address(), port); + ::asio::ip::tcp::endpoint endpoint(iter->endpoint().address(), port); auto self = this->shared_from_this(); delegate_->connect( endpoint, host, source_port, @@ -193,7 +193,7 @@ struct http_async_connection ec); })); } else { - set_errors(ec ? ec : asio::error::host_not_found); + set_errors(ec ? ec : ::asio::error::host_not_found); boost::iterator_range range; if (callback) callback(range, ec); } @@ -231,7 +231,7 @@ struct http_async_connection auto self = this->shared_from_this(); delegate_->read_some( - asio::mutable_buffers_1(this->part.data(), + ::asio::mutable_buffers_1(this->part.data(), this->part.size()), request_strand_.wrap([=] (std::error_code const &ec, std::size_t bytes_transferred) { @@ -239,7 +239,7 @@ struct http_async_connection ec, bytes_transferred); })); } else { - set_errors(is_timedout_ ? asio::error::timed_out : ec); + set_errors(is_timedout_ ? ::asio::error::timed_out : ec); } } @@ -250,19 +250,19 @@ struct http_async_connection static const long short_read_error = 335544539; bool is_ssl_short_read_error = #ifdef BOOST_NETWORK_ENABLE_HTTPS - ec.category() == asio::error::ssl_category && + ec.category() == ::asio::error::ssl_category && ec.value() == short_read_error; #else false && short_read_error; #endif if (!is_timedout_ && - (!ec || ec == asio::error::eof || is_ssl_short_read_error)) { + (!ec || ec == ::asio::error::eof || is_ssl_short_read_error)) { logic::tribool parsed_ok; size_t remainder; auto self = this->shared_from_this(); switch (state) { case version: - if (ec == asio::error::eof) return; + if (ec == ::asio::error::eof) return; parsed_ok = this->parse_version( delegate_, request_strand_.wrap([=] (std::error_code const &ec, @@ -275,7 +275,7 @@ struct http_async_connection return; } case status: - if (ec == asio::error::eof) return; + if (ec == ::asio::error::eof) return; parsed_ok = this->parse_status( delegate_, request_strand_.wrap([=] (std::error_code const &ec, @@ -288,7 +288,7 @@ struct http_async_connection return; } case status_message: - if (ec == asio::error::eof) return; + if (ec == ::asio::error::eof) return; parsed_ok = this->parse_status_message( delegate_, request_strand_.wrap([=] (std::error_code const &, std::size_t bytes_transferred) { @@ -300,7 +300,7 @@ struct http_async_connection return; } case headers: - if (ec == asio::error::eof) return; + if (ec == ::asio::error::eof) return; // In the following, remainder is the number of bytes that remain in // the buffer. We need this in the body processing to make sure that // the data remaining in the buffer is dealt with before another call @@ -352,7 +352,7 @@ struct http_async_connection auto self = this->shared_from_this(); delegate_->read_some( - asio::mutable_buffers_1(this->part.data(), + ::asio::mutable_buffers_1(this->part.data(), this->part.size()), request_strand_.wrap([=] (std::error_code const &ec, std::size_t bytes_transferred) { @@ -374,7 +374,7 @@ struct http_async_connection } return; case body: - if (ec == asio::error::eof || is_ssl_short_read_error) { + if (ec == ::asio::error::eof || is_ssl_short_read_error) { // Here we're handling the case when the connection has been closed // from the server side, or at least that the end of file has been // reached while reading the socket. This signals the end of the @@ -420,7 +420,7 @@ struct http_async_connection callback(make_iterator_range(begin, end), ec); auto self = this->shared_from_this(); delegate_->read_some( - asio::mutable_buffers_1(this->part.data(), + ::asio::mutable_buffers_1(this->part.data(), this->part.size()), request_strand_.wrap([=] (std::error_code const &ec, std::size_t bytes_transferred) { @@ -446,7 +446,7 @@ struct http_async_connection BOOST_ASSERT(false && "Bug, report this to the developers!"); } } else { - std::system_error error(is_timedout_ ? asio::error::timed_out + std::system_error error(is_timedout_ ? ::asio::error::timed_out : ec); this->source_promise.set_exception(std::make_exception_ptr(error)); this->destination_promise.set_exception(std::make_exception_ptr(error)); @@ -506,14 +506,14 @@ struct http_async_connection } int timeout_; - asio::deadline_timer timer_; + ::asio::deadline_timer timer_; bool is_timedout_; bool follow_redirect_; resolver_type& resolver_; resolve_function resolve_; - asio::io_service::strand request_strand_; + ::asio::io_service::strand request_strand_; connection_delegate_ptr delegate_; - asio::streambuf command_streambuf; + ::asio::streambuf command_streambuf; string_type method; }; diff --git a/boost/network/protocol/http/client/connection/async_protocol_handler.hpp b/boost/network/protocol/http/client/connection/async_protocol_handler.hpp index a860efb61..b35086206 100644 --- a/boost/network/protocol/http/client/connection/async_protocol_handler.hpp +++ b/boost/network/protocol/http/client/connection/async_protocol_handler.hpp @@ -139,7 +139,7 @@ struct http_async_protocol_handler { std::end(result_range)); part_begin = part.begin(); delegate_->read_some( - asio::mutable_buffers_1(part.data(), part.size()), + ::asio::mutable_buffers_1(part.data(), part.size()), callback); } return parsed_ok; @@ -185,7 +185,7 @@ struct http_async_protocol_handler { std::end(result_range)); part_begin = part.begin(); delegate_->read_some( - asio::mutable_buffers_1(part.data(), part.size()), + ::asio::mutable_buffers_1(part.data(), part.size()), callback); } return parsed_ok; @@ -230,7 +230,7 @@ struct http_async_protocol_handler { std::end(result_range)); part_begin = part.begin(); delegate_->read_some( - asio::mutable_buffers_1(part.data(), part.size()), + ::asio::mutable_buffers_1(part.data(), part.size()), callback); } return parsed_ok; @@ -317,7 +317,7 @@ struct http_async_protocol_handler { std::end(result_range)); part_begin = part.begin(); delegate_->read_some( - asio::mutable_buffers_1(part.data(), part.size()), + ::asio::mutable_buffers_1(part.data(), part.size()), callback); } return std::make_tuple( @@ -331,7 +331,7 @@ struct http_async_protocol_handler { partial_parsed.append(part_begin, bytes); part_begin = part.begin(); delegate_->read_some( - asio::mutable_buffers_1(part.data(), part.size()), callback); + ::asio::mutable_buffers_1(part.data(), part.size()), callback); } typedef response_parser response_parser_type; diff --git a/boost/network/protocol/http/client/connection/connection_delegate.hpp b/boost/network/protocol/http/client/connection/connection_delegate.hpp index fb18a04a1..c3a2f2acb 100644 --- a/boost/network/protocol/http/client/connection/connection_delegate.hpp +++ b/boost/network/protocol/http/client/connection/connection_delegate.hpp @@ -18,14 +18,14 @@ namespace http { namespace impl { struct connection_delegate { - virtual void connect(asio::ip::tcp::endpoint &endpoint, std::string host, + virtual void connect(::asio::ip::tcp::endpoint &endpoint, std::string host, std::uint16_t source_port, std::function handler) = 0; virtual void write( - asio::streambuf &command_streambuf, + ::asio::streambuf &command_streambuf, std::function handler) = 0; virtual void read_some( - asio::mutable_buffers_1 const &read_buffer, + ::asio::mutable_buffers_1 const &read_buffer, std::function handler) = 0; virtual void disconnect() = 0; virtual ~connection_delegate() = default; 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 7a78002e5..f2b17e57e 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,7 @@ 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( - asio::io_service& service, bool https, bool always_verify_peer, + ::asio::io_service& 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/normal_delegate.hpp b/boost/network/protocol/http/client/connection/normal_delegate.hpp index eb8b43a69..daa711299 100644 --- a/boost/network/protocol/http/client/connection/normal_delegate.hpp +++ b/boost/network/protocol/http/client/connection/normal_delegate.hpp @@ -22,15 +22,15 @@ namespace http { namespace impl { struct normal_delegate : connection_delegate { - explicit normal_delegate(asio::io_service &service); + explicit normal_delegate(::asio::io_service &service); - void connect(asio::ip::tcp::endpoint &endpoint, std::string host, + void connect(::asio::ip::tcp::endpoint &endpoint, std::string host, std::uint16_t source_port, std::function handler) override; - void write(asio::streambuf &command_streambuf, + void write(::asio::streambuf &command_streambuf, std::function handler) override; - void read_some(asio::mutable_buffers_1 const &read_buffer, + void read_some(::asio::mutable_buffers_1 const &read_buffer, std::function handler) override; void disconnect() override; @@ -40,8 +40,8 @@ struct normal_delegate : connection_delegate { normal_delegate &operator=(normal_delegate) = delete; private: - asio::io_service &service_; - std::unique_ptr socket_; + ::asio::io_service &service_; + std::unique_ptr<::asio::ip::tcp::socket> socket_; }; } // namespace impl diff --git a/boost/network/protocol/http/client/connection/normal_delegate.ipp b/boost/network/protocol/http/client/connection/normal_delegate.ipp index 091313c99..78f529263 100644 --- a/boost/network/protocol/http/client/connection/normal_delegate.ipp +++ b/boost/network/protocol/http/client/connection/normal_delegate.ipp @@ -16,31 +16,31 @@ #include boost::network::http::impl::normal_delegate::normal_delegate( - asio::io_service &service) + ::asio::io_service &service) : service_(service) {} void boost::network::http::impl::normal_delegate::connect( - asio::ip::tcp::endpoint &endpoint, std::string host, + ::asio::ip::tcp::endpoint &endpoint, std::string host, std::uint16_t source_port, std::function handler) { // TODO(dberris): review parameter necessity. (void)host; - socket_.reset(new asio::ip::tcp::socket( + socket_.reset(new ::asio::ip::tcp::socket( service_, - asio::ip::tcp::endpoint(asio::ip::address(), source_port))); + ::asio::ip::tcp::endpoint(::asio::ip::address(), source_port))); socket_->async_connect(endpoint, handler); } void boost::network::http::impl::normal_delegate::write( - asio::streambuf &command_streambuf, + ::asio::streambuf &command_streambuf, std::function handler) { - asio::async_write(*socket_, command_streambuf, handler); + ::asio::async_write(*socket_, command_streambuf, handler); } void boost::network::http::impl::normal_delegate::read_some( - asio::mutable_buffers_1 const &read_buffer, + ::asio::mutable_buffers_1 const &read_buffer, std::function handler) { socket_->async_read_some(read_buffer, handler); } @@ -48,7 +48,7 @@ void boost::network::http::impl::normal_delegate::read_some( void boost::network::http::impl::normal_delegate::disconnect() { if (socket_.get() && socket_->is_open()) { std::error_code ignored; - socket_->shutdown(asio::ip::tcp::socket::shutdown_both, ignored); + socket_->shutdown(::asio::ip::tcp::socket::shutdown_both, ignored); if (!ignored) { socket_->close(ignored); } diff --git a/boost/network/protocol/http/client/connection/ssl_delegate.hpp b/boost/network/protocol/http/client/connection/ssl_delegate.hpp index 0916af235..d6fcee3fe 100644 --- a/boost/network/protocol/http/client/connection/ssl_delegate.hpp +++ b/boost/network/protocol/http/client/connection/ssl_delegate.hpp @@ -24,7 +24,7 @@ namespace impl { struct ssl_delegate : public connection_delegate, public std::enable_shared_from_this { - ssl_delegate(asio::io_service &service, bool always_verify_peer, + ssl_delegate(::asio::io_service &service, bool always_verify_peer, optional certificate_filename, optional verify_path, optional certificate_file, @@ -32,20 +32,20 @@ struct ssl_delegate : public connection_delegate, optional ciphers, optional sni_hostname, long ssl_options); - void connect(asio::ip::tcp::endpoint &endpoint, std::string host, + void connect(::asio::ip::tcp::endpoint &endpoint, std::string host, std::uint16_t source_port, std::function handler) override; void write( - asio::streambuf &command_streambuf, + ::asio::streambuf &command_streambuf, std::function handler) override; void read_some( - asio::mutable_buffers_1 const &read_buffer, + ::asio::mutable_buffers_1 const &read_buffer, std::function handler) override; void disconnect() override; ~ssl_delegate() override; private: - asio::io_service &service_; + ::asio::io_service &service_; optional certificate_filename_; optional verify_path_; optional certificate_file_; @@ -53,9 +53,9 @@ struct ssl_delegate : public connection_delegate, optional ciphers_; optional sni_hostname_; long ssl_options_; - std::unique_ptr context_; - std::unique_ptr tcp_socket_; - std::unique_ptr > socket_; + std::unique_ptr<::asio::ssl::context> context_; + std::unique_ptr<::asio::ip::tcp::socket> tcp_socket_; + std::unique_ptr<::asio::ssl::stream<::asio::ip::tcp::socket &> > socket_; bool always_verify_peer_; ssl_delegate(ssl_delegate const &); // = delete diff --git a/boost/network/protocol/http/client/connection/ssl_delegate.ipp b/boost/network/protocol/http/client/connection/ssl_delegate.ipp index b303a24de..f3b179d01 100644 --- a/boost/network/protocol/http/client/connection/ssl_delegate.ipp +++ b/boost/network/protocol/http/client/connection/ssl_delegate.ipp @@ -13,7 +13,7 @@ #include boost::network::http::impl::ssl_delegate::ssl_delegate( - asio::io_service &service, bool always_verify_peer, + ::asio::io_service &service, bool always_verify_peer, optional certificate_filename, optional verify_path, optional certificate_file, optional private_key_file, optional ciphers, @@ -29,11 +29,11 @@ boost::network::http::impl::ssl_delegate::ssl_delegate( always_verify_peer_(always_verify_peer) {} void boost::network::http::impl::ssl_delegate::connect( - asio::ip::tcp::endpoint &endpoint, std::string host, + ::asio::ip::tcp::endpoint &endpoint, std::string host, std::uint16_t source_port, std::function handler) { context_.reset( - new asio::ssl::context(asio::ssl::context::method::sslv23_client)); + new ::asio::ssl::context(::asio::ssl::context::method::sslv23_client)); if (ciphers_) { ::SSL_CTX_set_cipher_list(context_->native_handle(), ciphers_->c_str()); } @@ -41,37 +41,37 @@ void boost::network::http::impl::ssl_delegate::connect( context_->set_options(ssl_options_); } else { // By default, disable v3 support. - context_->set_options(asio::ssl::context::no_sslv3); + context_->set_options(::asio::ssl::context::no_sslv3); } if (certificate_filename_ || verify_path_) { - context_->set_verify_mode(asio::ssl::context::verify_peer); + context_->set_verify_mode(::asio::ssl::context::verify_peer); if (certificate_filename_) context_->load_verify_file(*certificate_filename_); if (verify_path_) context_->add_verify_path(*verify_path_); } else { if (always_verify_peer_) { - context_->set_verify_mode(asio::ssl::context::verify_peer); + context_->set_verify_mode(::asio::ssl::context::verify_peer); // use openssl default verify paths. uses openssl environment variables // SSL_CERT_DIR, SSL_CERT_FILE context_->set_default_verify_paths(); } else { - context_->set_verify_mode(asio::ssl::context::verify_none); + context_->set_verify_mode(::asio::ssl::context::verify_none); } } if (certificate_file_) - context_->use_certificate_file(*certificate_file_, asio::ssl::context::pem); + context_->use_certificate_file(*certificate_file_, ::asio::ssl::context::pem); if (private_key_file_) - context_->use_private_key_file(*private_key_file_, asio::ssl::context::pem); + context_->use_private_key_file(*private_key_file_, ::asio::ssl::context::pem); - tcp_socket_.reset(new asio::ip::tcp::socket( - service_, asio::ip::tcp::endpoint(asio::ip::tcp::v4(), source_port))); - socket_.reset(new asio::ssl::stream( + tcp_socket_.reset(new ::asio::ip::tcp::socket( + service_, ::asio::ip::tcp::endpoint(::asio::ip::tcp::v4(), source_port))); + socket_.reset(new ::asio::ssl::stream<::asio::ip::tcp::socket &>( *(tcp_socket_.get()), *context_)); if (sni_hostname_) SSL_set_tlsext_host_name(socket_->native_handle(), sni_hostname_->c_str()); if (always_verify_peer_) - socket_->set_verify_callback(asio::ssl::rfc2818_verification(host)); + socket_->set_verify_callback(::asio::ssl::rfc2818_verification(host)); auto self = this->shared_from_this(); socket_->lowest_layer().async_connect( endpoint, @@ -82,20 +82,20 @@ void boost::network::http::impl::ssl_delegate::handle_connected( std::error_code const &ec, std::function handler) { if (!ec) { - socket_->async_handshake(asio::ssl::stream_base::client, handler); + socket_->async_handshake(::asio::ssl::stream_base::client, handler); } else { handler(ec); } } void boost::network::http::impl::ssl_delegate::write( - asio::streambuf &command_streambuf, + ::asio::streambuf &command_streambuf, std::function handler) { - asio::async_write(*socket_, command_streambuf, handler); + ::asio::async_write(*socket_, command_streambuf, handler); } void boost::network::http::impl::ssl_delegate::read_some( - asio::mutable_buffers_1 const &read_buffer, + ::asio::mutable_buffers_1 const &read_buffer, std::function handler) { socket_->async_read_some(read_buffer, handler); } @@ -103,7 +103,7 @@ void boost::network::http::impl::ssl_delegate::read_some( void boost::network::http::impl::ssl_delegate::disconnect() { if (socket_.get() && socket_->lowest_layer().is_open()) { std::error_code ignored; - socket_->lowest_layer().shutdown(asio::ip::tcp::socket::shutdown_both, + socket_->lowest_layer().shutdown(::asio::ip::tcp::socket::shutdown_both, ignored); if (!ignored) { socket_->lowest_layer().close(ignored); diff --git a/boost/network/protocol/http/client/connection/sync_base.hpp b/boost/network/protocol/http/client/connection/sync_base.hpp index 4d940c334..4cf9abeba 100644 --- a/boost/network/protocol/http/client/connection/sync_base.hpp +++ b/boost/network/protocol/http/client/connection/sync_base.hpp @@ -41,8 +41,8 @@ struct sync_connection_base_impl { void init_socket(Socket& socket_, resolver_type& resolver_, string_type /*unused*/ const& hostname, string_type const& port, resolver_function_type resolve_) { - using asio::ip::tcp; - std::error_code error = asio::error::host_not_found; + using ::asio::ip::tcp; + std::error_code error = ::asio::error::host_not_found; typename resolver_type::iterator endpoint_iterator, end; boost::tie(endpoint_iterator, end) = resolve_(resolver_, hostname, port); while (error && endpoint_iterator != end) { @@ -58,8 +58,8 @@ struct sync_connection_base_impl { template void read_status(Socket& socket_, basic_response& response_, - asio::streambuf& response_buffer) { - asio::read_until(socket_, response_buffer, "\r\n"); + ::asio::streambuf& response_buffer) { + ::asio::read_until(socket_, response_buffer, "\r\n"); std::istream response_stream(&response_buffer); string_type http_version; unsigned int status_code; @@ -78,8 +78,8 @@ struct sync_connection_base_impl { template void read_headers(Socket& socket_, basic_response& response_, - asio::streambuf& response_buffer) { - asio::read_until(socket_, response_buffer, "\r\n\r\n"); + ::asio::streambuf& response_buffer) { + ::asio::read_until(socket_, response_buffer, "\r\n\r\n"); std::istream response_stream(&response_buffer); string_type header_line, name; while (std::getline(response_stream, header_line) && header_line != "\r") { @@ -101,7 +101,7 @@ struct sync_connection_base_impl { template void send_request_impl(Socket& socket_, string_type /*unused*/ const& method, - asio::streambuf& request_buffer) { + ::asio::streambuf& request_buffer) { // TODO(dberris): review parameter necessity. (void)method; @@ -110,7 +110,7 @@ struct sync_connection_base_impl { template void read_body_normal(Socket& socket_, basic_response& response_, - asio::streambuf& response_buffer, + ::asio::streambuf& response_buffer, typename ostringstream::type& body_stream) { // TODO(dberris): review parameter necessity. (void)response_; @@ -118,7 +118,7 @@ struct sync_connection_base_impl { std::error_code error; if (response_buffer.size() > 0) body_stream << &response_buffer; - while (asio::read(socket_, response_buffer, asio::transfer_at_least(1), + while (::asio::read(socket_, response_buffer, ::asio::transfer_at_least(1), error)) { body_stream << &response_buffer; } @@ -127,7 +127,7 @@ struct sync_connection_base_impl { template void read_body_transfer_chunk_encoding( Socket& socket_, basic_response& response_, - asio::streambuf& response_buffer, + ::asio::streambuf& response_buffer, typename ostringstream::type& body_stream) { std::error_code error; // look for the content-length header @@ -146,7 +146,7 @@ struct sync_connection_base_impl { do { std::size_t chunk_size_line = read_until(socket_, response_buffer, "\r\n", error); - if ((chunk_size_line == 0) && (error != asio::error::eof)) + if ((chunk_size_line == 0) && (error != ::asio::error::eof)) throw std::system_error(error); std::size_t chunk_size = 0; string_type data; @@ -159,7 +159,7 @@ struct sync_connection_base_impl { if (chunk_size == 0) { stopping = true; if (!read_until(socket_, response_buffer, "\r\n", error) && - (error != asio::error::eof)) + (error != ::asio::error::eof)) throw std::system_error(error); } else { bool stopping_inner = false; @@ -169,9 +169,9 @@ struct sync_connection_base_impl { (chunk_size + 2) - response_buffer.size(); std::size_t chunk_bytes_read = read(socket_, response_buffer, - asio::transfer_at_least(bytes_to_read), error); + ::asio::transfer_at_least(bytes_to_read), error); if (chunk_bytes_read == 0) { - if (error != asio::error::eof) throw std::system_error(error); + if (error != ::asio::error::eof) throw std::system_error(error); stopping_inner = true; } } @@ -200,8 +200,8 @@ struct sync_connection_base_impl { return; } size_t bytes_read = 0; - while ((bytes_read = asio::read(socket_, response_buffer, - asio::transfer_at_least(1), error))) { + while ((bytes_read = ::asio::read(socket_, response_buffer, + ::asio::transfer_at_least(1), error))) { body_stream << &response_buffer; length -= bytes_read; if ((length <= 0) || error) break; @@ -211,7 +211,7 @@ struct sync_connection_base_impl { template void read_body(Socket& socket_, basic_response& response_, - asio::streambuf& response_buffer) { + ::asio::streambuf& response_buffer) { typename ostringstream::type body_stream; // TODO(dberris): tag dispatch based on whether it's HTTP 1.0 or HTTP 1.1 if (version_major == 1 && version_minor == 0) { @@ -282,11 +282,11 @@ struct sync_connection_base { basic_request const& request_, body_generator_function_type generator) = 0; virtual void read_status(basic_response& response_, - asio::streambuf& response_buffer) = 0; + ::asio::streambuf& response_buffer) = 0; virtual void read_headers(basic_response& response_, - asio::streambuf& response_buffer) = 0; + ::asio::streambuf& response_buffer) = 0; virtual void read_body(basic_response& response_, - asio::streambuf& response_buffer) = 0; + ::asio::streambuf& response_buffer) = 0; virtual bool is_open() = 0; virtual void close_socket() = 0; virtual ~sync_connection_base() = default; diff --git a/boost/network/protocol/http/client/connection/sync_normal.hpp b/boost/network/protocol/http/client/connection/sync_normal.hpp index 27e1e1cc6..0d252766b 100644 --- a/boost/network/protocol/http/client/connection/sync_normal.hpp +++ b/boost/network/protocol/http/client/connection/sync_normal.hpp @@ -61,7 +61,7 @@ struct http_sync_connection void send_request_impl(string_type const& method, basic_request const& request_, body_generator_function_type generator) { - asio::streambuf request_buffer; + ::asio::streambuf request_buffer; linearize( request_, method, version_major, version_minor, std::ostreambuf_iterator::type>(&request_buffer)); @@ -86,17 +86,17 @@ struct http_sync_connection } void read_status(basic_response& response_, - asio::streambuf& response_buffer) { + ::asio::streambuf& response_buffer) { connection_base::read_status(socket_, response_, response_buffer); } void read_headers(basic_response& response, - asio::streambuf& response_buffer) { + ::asio::streambuf& response_buffer) { connection_base::read_headers(socket_, response, response_buffer); } void read_body(basic_response& response_, - asio::streambuf& response_buffer) { + ::asio::streambuf& response_buffer) { connection_base::read_body(socket_, response_, response_buffer); typename headers_range >::type connection_range = headers(response_)["Connection"]; @@ -117,7 +117,7 @@ struct http_sync_connection return; } std::error_code ignored; - socket_.shutdown(asio::ip::tcp::socket::shutdown_both, ignored); + socket_.shutdown(::asio::ip::tcp::socket::shutdown_both, ignored); if (ignored) { return; } @@ -132,10 +132,10 @@ struct http_sync_connection } int timeout_; - asio::deadline_timer timer_; + ::asio::deadline_timer timer_; resolver_type& resolver_; resolver_function_type resolve_; - asio::ip::tcp::socket socket_; + ::asio::ip::tcp::socket socket_; }; } // namespace impl diff --git a/boost/network/protocol/http/client/connection/sync_ssl.hpp b/boost/network/protocol/http/client/connection/sync_ssl.hpp index d973fc0d6..f115066a7 100644 --- a/boost/network/protocol/http/client/connection/sync_ssl.hpp +++ b/boost/network/protocol/http/client/connection/sync_ssl.hpp @@ -63,7 +63,7 @@ struct https_sync_connection timer_(resolver.get_io_service()), resolver_(resolver), resolve_(std::move(resolve)), - context_(resolver.get_io_service(), asio::ssl::context::sslv23_client), + context_(resolver.get_io_service(), ::asio::ssl::context::sslv23_client), socket_(resolver.get_io_service(), context_) { if (ciphers) { ::SSL_CTX_set_cipher_list(context_.native_handle(), ciphers->c_str()); @@ -72,7 +72,7 @@ struct https_sync_connection context_.set_options(ssl_options); } if (certificate_filename || verify_path) { - context_.set_verify_mode(asio::ssl::context::verify_peer); + context_.set_verify_mode(::asio::ssl::context::verify_peer); // FIXME make the certificate filename and verify path parameters // be // optional ranges @@ -81,14 +81,14 @@ struct https_sync_connection if (verify_path) context_.add_verify_path(*verify_path); } else { if (always_verify_peer) - context_.set_verify_mode(asio::ssl::context_base::verify_peer); + context_.set_verify_mode(::asio::ssl::context_base::verify_peer); else - context_.set_verify_mode(asio::ssl::context_base::verify_none); + context_.set_verify_mode(::asio::ssl::context_base::verify_none); } if (certificate_file) - context_.use_certificate_file(*certificate_file, asio::ssl::context::pem); + context_.use_certificate_file(*certificate_file, ::asio::ssl::context::pem); if (private_key_file) - context_.use_private_key_file(*private_key_file, asio::ssl::context::pem); + context_.use_private_key_file(*private_key_file, ::asio::ssl::context::pem); if (sni_hostname) SSL_set_tlsext_host_name(socket_.native_handle(), sni_hostname->c_str()); } @@ -97,13 +97,13 @@ struct https_sync_connection string_type const& port) { connection_base::init_socket(socket_.lowest_layer(), resolver_, hostname, port, resolve_); - socket_.handshake(asio::ssl::stream_base::client); + socket_.handshake(::asio::ssl::stream_base::client); } void send_request_impl(string_type /*unused*/ const& method, basic_request const& request_, body_generator_function_type generator) { - asio::streambuf request_buffer; + ::asio::streambuf request_buffer; linearize( request_, method, version_major, version_minor, std::ostreambuf_iterator::type>(&request_buffer)); @@ -127,17 +127,17 @@ struct https_sync_connection } void read_status(basic_response& response_, - asio::streambuf& response_buffer) { + ::asio::streambuf& response_buffer) { connection_base::read_status(socket_, response_, response_buffer); } void read_headers(basic_response& response_, - asio::streambuf& response_buffer) { + ::asio::streambuf& response_buffer) { connection_base::read_headers(socket_, response_, response_buffer); } void read_body(basic_response& response_, - asio::streambuf& response_buffer) { + ::asio::streambuf& response_buffer) { connection_base::read_body(socket_, response_, response_buffer); typename headers_range >::type connection_range = headers(response_)["Connection"]; @@ -155,7 +155,7 @@ struct https_sync_connection void close_socket() { timer_.cancel(); std::error_code ignored; - socket_.lowest_layer().shutdown(asio::ip::tcp::socket::shutdown_both, + socket_.lowest_layer().shutdown(::asio::ip::tcp::socket::shutdown_both, ignored); if (ignored) { return; @@ -173,11 +173,11 @@ struct https_sync_connection } int timeout_; - asio::deadline_timer timer_; + ::asio::deadline_timer timer_; resolver_type& resolver_; resolver_function_type resolve_; - asio::ssl::context context_; - asio::ssl::stream socket_; + ::asio::ssl::context context_; + ::asio::ssl::stream<::asio::ip::tcp::socket> socket_; }; } // namespace impl diff --git a/boost/network/protocol/http/client/options.hpp b/boost/network/protocol/http/client/options.hpp index 2c109a88d..d91e9fe5a 100644 --- a/boost/network/protocol/http/client/options.hpp +++ b/boost/network/protocol/http/client/options.hpp @@ -133,8 +133,8 @@ class client_options { return *this; } - /// Provide an `asio::io_service` hosted in a shared pointer. - client_options& io_service(std::shared_ptr v) { + /// Provide an `::asio::io_service` hosted in a shared pointer. + client_options& io_service(std::shared_ptr<::asio::io_service> v) { io_service_ = v; return *this; } @@ -184,7 +184,7 @@ class client_options { long openssl_options() const { return openssl_options_; } - std::shared_ptr io_service() const { return io_service_; } + std::shared_ptr<::asio::io_service> io_service() const { return io_service_; } bool always_verify_peer() const { return always_verify_peer_; } @@ -200,7 +200,7 @@ class client_options { boost::optional openssl_ciphers_; boost::optional openssl_sni_hostname_; long openssl_options_; - std::shared_ptr io_service_; + std::shared_ptr<::asio::io_service> io_service_; bool always_verify_peer_; int timeout_; }; diff --git a/boost/network/protocol/http/client/pimpl.hpp b/boost/network/protocol/http/client/pimpl.hpp index 2f7f28c67..33dc5ae92 100644 --- a/boost/network/protocol/http/client/pimpl.hpp +++ b/boost/network/protocol/http/client/pimpl.hpp @@ -74,7 +74,7 @@ struct basic_client_impl optional const& private_key_file, optional const& ciphers, optional const& sni_hostname, long ssl_options, - std::shared_ptr service, int timeout) + std::shared_ptr<::asio::io_service> service, int timeout) : base_type(cache_resolved, follow_redirect, always_verify_peer, timeout, service, certificate_filename, verify_path, certificate_file, private_key_file, ciphers, sni_hostname, ssl_options) {} diff --git a/boost/network/protocol/http/client/sync_impl.hpp b/boost/network/protocol/http/client/sync_impl.hpp index 4f07446f5..f902b73a9 100644 --- a/boost/network/protocol/http/client/sync_impl.hpp +++ b/boost/network/protocol/http/client/sync_impl.hpp @@ -37,8 +37,8 @@ struct sync_client typedef std::function body_generator_function_type; friend struct basic_client_impl; - std::shared_ptr service_ptr; - asio::io_service& service_; + std::shared_ptr<::asio::io_service> service_ptr; + ::asio::io_service& service_; resolver_type resolver_; optional certificate_filename_; optional verify_path_; @@ -51,7 +51,7 @@ struct sync_client sync_client( bool cache_resolved, bool follow_redirect, bool always_verify_peer, - int timeout, std::shared_ptr service, + int timeout, std::shared_ptr<::asio::io_service> service, optional certificate_filename = optional(), optional verify_path = optional(), optional certificate_file = optional(), @@ -61,7 +61,7 @@ struct sync_client long ssl_options = 0) : connection_base(cache_resolved, follow_redirect, timeout), service_ptr(service.get() ? service - : std::make_shared()), + : std::make_shared<::asio::io_service>()), service_(*service_ptr), resolver_(service_), certificate_filename_(std::move(certificate_filename)), diff --git a/boost/network/protocol/http/impl/response.ipp b/boost/network/protocol/http/impl/response.ipp index 24055776c..18039e6a7 100644 --- a/boost/network/protocol/http/impl/response.ipp +++ b/boost/network/protocol/http/impl/response.ipp @@ -100,9 +100,9 @@ struct basic_response { /// underlying memory blocks, therefore the reply object must remain /// valid and /// not be changed until the write operation has completed. - std::vector to_buffers() { - using asio::const_buffer; - using asio::buffer; + std::vector<::asio::const_buffer> to_buffers() { + using ::asio::const_buffer; + using ::asio::buffer; static const char name_value_separator[] = {':', ' '}; static const char crlf[] = {'\r', '\n'}; std::vector buffers; @@ -408,13 +408,13 @@ struct basic_response { } } - asio::const_buffer trim_null(asio::const_buffer buffer) { - std::size_t size = asio::buffer_size(buffer); - return asio::buffer(buffer, size - 1); + ::asio::const_buffer trim_null(::asio::const_buffer buffer) { + std::size_t size = ::asio::buffer_size(buffer); + return ::asio::buffer(buffer, size - 1); } - asio::const_buffer to_buffer(status_type status) { - using asio::buffer; + ::asio::const_buffer to_buffer(status_type status) { + using ::asio::buffer; switch (status) { // 2xx Success case basic_response::ok: diff --git a/boost/network/protocol/http/policies/async_resolver.hpp b/boost/network/protocol/http/policies/async_resolver.hpp index ac30d1586..ebbba6679 100644 --- a/boost/network/protocol/http/policies/async_resolver.hpp +++ b/boost/network/protocol/http/policies/async_resolver.hpp @@ -39,8 +39,8 @@ struct async_resolver : std::enable_shared_from_this > { protected: bool cache_resolved_; endpoint_cache endpoint_cache_; - std::shared_ptr service_; - std::shared_ptr resolver_strand_; + std::shared_ptr<::asio::io_service> service_; + std::shared_ptr<::asio::io_service::strand> resolver_strand_; explicit async_resolver(bool cache_resolved) : cache_resolved_(cache_resolved), endpoint_cache_() {} diff --git a/boost/network/protocol/http/policies/pooled_connection.hpp b/boost/network/protocol/http/policies/pooled_connection.hpp index 845dd0d4a..ab5ebca57 100644 --- a/boost/network/protocol/http/policies/pooled_connection.hpp +++ b/boost/network/protocol/http/policies/pooled_connection.hpp @@ -110,12 +110,12 @@ struct pooled_connection_policy : resolver_policy::type { response_ << ::boost::network::source(request_.host()); pimpl->send_request_impl(method, request_, generator); - asio::streambuf response_buffer; + ::asio::streambuf response_buffer; try { pimpl->read_status(response_, response_buffer); } catch (std::system_error& e) { - if (!retry && e.code() == asio::error::eof) { + if (!retry && e.code() == ::asio::error::eof) { retry = true; pimpl->init_socket(request_.host(), std::to_string(request_.port())); diff --git a/boost/network/protocol/http/policies/simple_connection.hpp b/boost/network/protocol/http/policies/simple_connection.hpp index 5a96c5ade..118b41096 100644 --- a/boost/network/protocol/http/policies/simple_connection.hpp +++ b/boost/network/protocol/http/policies/simple_connection.hpp @@ -80,7 +80,7 @@ struct simple_connection_policy : resolver_policy::type { response_ = basic_response(); response_ << network::source(request_.host()); - asio::streambuf response_buffer; + ::asio::streambuf response_buffer; pimpl->read_status(response_, response_buffer); pimpl->read_headers(response_, response_buffer); if (get_body) pimpl->read_body(response_, response_buffer); diff --git a/boost/network/protocol/http/server/async_connection.hpp b/boost/network/protocol/http/server/async_connection.hpp index 4a6dbdf63..915c6fb98 100644 --- a/boost/network/protocol/http/server/async_connection.hpp +++ b/boost/network/protocol/http/server/async_connection.hpp @@ -183,7 +183,7 @@ struct async_connection public: async_connection( - asio::io_service& io_service, Handler& handler, + ::asio::io_service& io_service, Handler& handler, utils::thread_pool& thread_pool, std::shared_ptr ctx = std::shared_ptr()) : strand(io_service), @@ -206,7 +206,7 @@ struct async_connection ~async_connection() throw() { std::error_code ignored; - socket_.shutdown(asio::ip::tcp::socket::shutdown_receive, ignored); + socket_.shutdown(::asio::ip::tcp::socket::shutdown_receive, ignored); } /** @@ -321,7 +321,7 @@ struct async_connection */ template typename disable_if< - is_base_of, void>::type + is_base_of<::asio::const_buffer, typename Range::value_type>, void>::type write(Range const& range, Callback const& callback) { lock_guard lock(headers_mutex); if (error_encountered) @@ -330,15 +330,15 @@ struct async_connection } /** - * Writes a given set of `asio::const_buffer`s out using a more efficient + * Writes a given set of `::asio::const_buffer`s out using a more efficient * implementation. * - * @param[in] seq A sequence of `asio::const_buffer` objects. + * @param[in] seq A sequence of `::asio::const_buffer` objects. * @param[in] callback A function of type `void(std::error_code)`. */ template typename enable_if< - is_base_of, + is_base_of<::asio::const_buffer, typename ConstBufferSeq::value_type>, void>::type write(ConstBufferSeq const& seq, Callback const& callback) { write_vec_impl(seq, callback, shared_array_list(), shared_buffers()); @@ -390,7 +390,7 @@ struct async_connection auto self = this->shared_from_this(); socket().async_read_some( - asio::buffer(read_buffer_), + ::asio::buffer(read_buffer_), strand.wrap([this, self, callback](std::error_code ec, size_t bytes_transferred) { this->wrap_read_handler(callback, ec, bytes_transferred); @@ -433,15 +433,15 @@ struct async_connection array; typedef std::list > array_list; typedef std::shared_ptr shared_array_list; - typedef std::shared_ptr > shared_buffers; + typedef std::shared_ptr > shared_buffers; typedef request_parser request_parser_type; typedef std::lock_guard lock_guard; typedef std::list > pending_actions_list; - asio::io_service::strand strand; + ::asio::io_service::strand strand; Handler& handler; utils::thread_pool& thread_pool_; - asio::streambuf headers_buffer; + ::asio::streambuf headers_buffer; boost::network::stream_handler socket_; bool handshake_done; volatile bool headers_already_sent, headers_in_progress; @@ -473,14 +473,14 @@ struct async_connection auto self = this->shared_from_this(); #ifdef BOOST_NETWORK_ENABLE_HTTPS if (socket_.is_ssl_enabled() && !handshake_done) { - socket_.async_handshake(asio::ssl::stream_base::server, + socket_.async_handshake(::asio::ssl::stream_base::server, [this, self, state](std::error_code ec) { handle_handshake(ec, state); }); } else { #endif socket_.async_read_some( - asio::buffer(read_buffer_), + ::asio::buffer(read_buffer_), strand.wrap([this, self, state](std::error_code ec, size_t bytes_transferred) { handle_read_data(state, ec, bytes_transferred); @@ -605,8 +605,8 @@ struct async_connection "text/plain\r\nContent-Length: 12\r\n\r\nBad Request."; auto self = this->shared_from_this(); - asio::async_write( - socket(), asio::buffer(bad_request, strlen(bad_request)), + ::asio::async_write( + socket(), ::asio::buffer(bad_request, strlen(bad_request)), strand.wrap([this, self](std::error_code ec, size_t bytes_transferred) { client_error_sent(ec, bytes_transferred); })); @@ -615,7 +615,7 @@ struct async_connection void client_error_sent(std::error_code const& ec, std::size_t) { if (!ec) { std::error_code ignored; - socket().shutdown(asio::ip::tcp::socket::shutdown_both, ignored); + socket().shutdown(::asio::ip::tcp::socket::shutdown_both, ignored); socket().close(ignored); } else { error_encountered = in_place(ec); @@ -626,7 +626,7 @@ struct async_connection if (headers_in_progress) return; headers_in_progress = true; auto self = this->shared_from_this(); - asio::async_write(socket(), headers_buffer, + ::asio::async_write(socket(), headers_buffer, strand.wrap([this, self, callback]( std::error_code ec, size_t bytes_transferred) { handle_write_headers(callback, ec, bytes_transferred); @@ -676,7 +676,7 @@ struct async_connection BOOST_NETWORK_HTTP_SERVER_CONNECTION_BUFFER_SIZE; shared_array_list temporaries = std::make_shared(); shared_buffers buffers = - std::make_shared >(0); + std::make_shared >(0); std::size_t range_size = boost::distance(range); buffers->reserve((range_size / connection_buffer_size) + @@ -688,7 +688,7 @@ struct async_connection std::shared_ptr new_array = std::make_shared(); boost::copy(range | sliced(0, slice_size), new_array->begin()); temporaries->push_back(new_array); - buffers->push_back(asio::buffer(new_array->data(), slice_size)); + buffers->push_back(::asio::buffer(new_array->data(), slice_size)); std::advance(start, slice_size); range = boost::make_iterator_range(start, end); range_size = boost::distance(range); @@ -718,7 +718,7 @@ struct async_connection pending_actions.push_back(continuation); return; } - asio::async_write( + ::asio::async_write( socket_, seq, [this, self, callback, temporaries, buffers]( std::error_code ec, size_t bytes_transferred) { handle_write(callback, temporaries, buffers, ec, bytes_transferred); diff --git a/boost/network/protocol/http/server/async_server.hpp b/boost/network/protocol/http/server/async_server.hpp index 954e0a5c3..8c12aee74 100644 --- a/boost/network/protocol/http/server/async_server.hpp +++ b/boost/network/protocol/http/server/async_server.hpp @@ -114,7 +114,7 @@ struct async_server_base : server_storage_base, socket_options_base { Handler &handler; string_type address_, port_; std::shared_ptr thread_pool; - asio::ip::tcp::acceptor acceptor; + ::asio::ip::tcp::acceptor acceptor; bool stopping; connection_ptr new_connection; std::mutex listening_mutex_; @@ -160,7 +160,7 @@ struct async_server_base : server_storage_base, socket_options_base { } void start_listening() { - using asio::ip::tcp; + using ::asio::ip::tcp; std::error_code error; // this allows repeated cycles of run -> stop -> run service_.reset(); @@ -185,7 +185,7 @@ struct async_server_base : server_storage_base, socket_options_base { << port_); return; } - acceptor.listen(asio::socket_base::max_connections, error); + acceptor.listen(::asio::socket_base::max_connections, error); if (error) { BOOST_NETWORK_MESSAGE("Error listening on socket: '" << error << "' on " << address_ << ":" << port_); diff --git a/boost/network/protocol/http/server/options.hpp b/boost/network/protocol/http/server/options.hpp index d3d9f03a1..fd90cc0a7 100644 --- a/boost/network/protocol/http/server/options.hpp +++ b/boost/network/protocol/http/server/options.hpp @@ -71,7 +71,7 @@ struct server_options { } /// Provides an Asio io_service for the server. Default is nullptr. - server_options &io_service(std::shared_ptr v) { + server_options &io_service(std::shared_ptr<::asio::io_service> v) { io_service_ = v; return *this; } @@ -120,26 +120,26 @@ struct server_options { /// Set the socket receive buffer size. Unset by default. server_options &receive_buffer_size( - asio::socket_base::receive_buffer_size v) { + ::asio::socket_base::receive_buffer_size v) { receive_buffer_size_ = v; return *this; } /// Set the send buffer size. Unset by default. - server_options &send_buffer_size(asio::socket_base::send_buffer_size v) { + server_options &send_buffer_size(::asio::socket_base::send_buffer_size v) { send_buffer_size_ = v; return *this; } /// Set the socket receive low watermark. Unset by default. server_options &receive_low_watermark( - asio::socket_base::receive_low_watermark v) { + ::asio::socket_base::receive_low_watermark v) { receive_low_watermark_ = v; return *this; } /// Set the socket send low watermark. Unset by default. - server_options &send_low_watermark(asio::socket_base::send_low_watermark v) { + server_options &send_low_watermark(::asio::socket_base::send_low_watermark v) { send_low_watermark_ = v; return *this; } @@ -151,7 +151,7 @@ struct server_options { } /// Returns the provided Asio io_service. - std::shared_ptr io_service() const { return io_service_; } + std::shared_ptr<::asio::io_service> io_service() const { return io_service_; } /// Returns the address to listen on. string_type address() const { return address_; } @@ -178,25 +178,25 @@ struct server_options { size_t linger_timeout() const { return linger_timeout_; } /// Returns the optional receive buffer size. - boost::optional receive_buffer_size() + boost::optional<::asio::socket_base::receive_buffer_size> receive_buffer_size() const { return receive_buffer_size_; } /// Returns the optional send buffer size. - boost::optional send_buffer_size() + boost::optional<::asio::socket_base::send_buffer_size> send_buffer_size() const { return send_buffer_size_; } /// Returns the optional receive low watermark. - boost::optional + boost::optional<::asio::socket_base::receive_low_watermark> receive_low_watermark() const { return receive_low_watermark_; } /// Returns the optional send low watermark. - boost::optional send_low_watermark() + boost::optional<::asio::socket_base::send_low_watermark> send_low_watermark() const { return send_low_watermark_; } @@ -229,7 +229,7 @@ struct server_options { } private: - std::shared_ptr io_service_; + std::shared_ptr<::asio::io_service> io_service_; Handler &handler_; string_type address_; string_type port_; @@ -238,11 +238,11 @@ struct server_options { bool non_blocking_io_; bool linger_; size_t linger_timeout_; - boost::optional receive_buffer_size_; - boost::optional send_buffer_size_; - boost::optional + boost::optional<::asio::socket_base::receive_buffer_size> receive_buffer_size_; + boost::optional<::asio::socket_base::send_buffer_size> send_buffer_size_; + boost::optional<::asio::socket_base::receive_low_watermark> receive_low_watermark_; - boost::optional send_low_watermark_; + boost::optional<::asio::socket_base::send_low_watermark> send_low_watermark_; std::shared_ptr thread_pool_; std::shared_ptr context_; }; diff --git a/boost/network/protocol/http/server/socket_options_base.hpp b/boost/network/protocol/http/server/socket_options_base.hpp index dc1bd15c5..4e5aa6390 100644 --- a/boost/network/protocol/http/server/socket_options_base.hpp +++ b/boost/network/protocol/http/server/socket_options_base.hpp @@ -14,15 +14,15 @@ namespace http { struct socket_options_base { protected: - asio::socket_base::reuse_address acceptor_reuse_address; - asio::socket_base::enable_connection_aborted acceptor_report_aborted; - boost::optional receive_buffer_size; - boost::optional send_buffer_size; - boost::optional + ::asio::socket_base::reuse_address acceptor_reuse_address; + ::asio::socket_base::enable_connection_aborted acceptor_report_aborted; + boost::optional<::asio::socket_base::receive_buffer_size> receive_buffer_size; + boost::optional<::asio::socket_base::send_buffer_size> send_buffer_size; + boost::optional<::asio::socket_base::receive_low_watermark> receive_low_watermark; - boost::optional send_low_watermark; + boost::optional<::asio::socket_base::send_low_watermark> send_low_watermark; bool non_blocking_io; - asio::socket_base::linger linger; + ::asio::socket_base::linger linger; template explicit socket_options_base(server_options const &options) @@ -35,12 +35,12 @@ struct socket_options_base { non_blocking_io(options.non_blocking_io()), linger(options.linger(), options.linger_timeout()) {} - void acceptor_options(asio::ip::tcp::acceptor &acceptor) { + void acceptor_options(::asio::ip::tcp::acceptor &acceptor) { acceptor.set_option(acceptor_reuse_address); acceptor.set_option(acceptor_report_aborted); } - void socket_options(asio::ip::tcp::socket &socket) { + void socket_options(::asio::ip::tcp::socket &socket) { std::error_code ignored; socket.non_blocking(non_blocking_io); socket.set_option(linger, ignored); diff --git a/boost/network/protocol/http/server/storage_base.hpp b/boost/network/protocol/http/server/storage_base.hpp index 9383e5e92..9e83ce2e6 100644 --- a/boost/network/protocol/http/server/storage_base.hpp +++ b/boost/network/protocol/http/server/storage_base.hpp @@ -22,11 +22,11 @@ struct server_storage_base { explicit server_storage_base(server_options const& options) : self_service_(options.io_service() ? options.io_service() - : std::make_shared()), + : std::make_shared<::asio::io_service>()), service_(*self_service_) {} - std::shared_ptr self_service_; - asio::io_service& service_; + std::shared_ptr<::asio::io_service> self_service_; + ::asio::io_service& service_; }; } /* http */ diff --git a/boost/network/protocol/http/traits/resolver.hpp b/boost/network/protocol/http/traits/resolver.hpp index cfcfc19fd..350fa2396 100644 --- a/boost/network/protocol/http/traits/resolver.hpp +++ b/boost/network/protocol/http/traits/resolver.hpp @@ -26,9 +26,9 @@ struct unsupported_tag; template struct resolver : mpl::if_, is_http >, - asio::ip::tcp::resolver, + ::asio::ip::tcp::resolver, typename mpl::if_, is_http >, - asio::ip::udp::resolver, + ::asio::ip::udp::resolver, unsupported_tag >::type> { static_assert(mpl::not_, is_tcp > >::value, "Transport protocol must be TCP or UDP"); diff --git a/boost/network/protocol/stream_handler.hpp b/boost/network/protocol/stream_handler.hpp index ae355b724..16fafc665 100644 --- a/boost/network/protocol/stream_handler.hpp +++ b/boost/network/protocol/stream_handler.hpp @@ -28,15 +28,15 @@ namespace boost { namespace network { -typedef asio::ip::tcp::socket tcp_socket; +typedef ::asio::ip::tcp::socket tcp_socket; #ifndef BOOST_NETWORK_ENABLE_HTTPS typedef tcp_socket stream_handler; typedef void ssl_context; #else -typedef asio::ssl::stream ssl_socket; -typedef asio::ssl::context ssl_context; +typedef ::asio::ssl::stream<::asio::ip::tcp::socket> ssl_socket; +typedef ::asio::ssl::context ssl_context; struct stream_handler { public: @@ -48,7 +48,7 @@ struct stream_handler { stream_handler(std::shared_ptr socket) : ssl_sock_(std::move(socket)), ssl_enabled(true) {} - stream_handler(asio::io_service& io, + stream_handler(::asio::io_service& io, std::shared_ptr ctx = std::shared_ptr()) { tcp_sock_ = std::make_shared(boost::ref(io)); @@ -117,13 +117,13 @@ struct stream_handler { } } - void shutdown(asio::socket_base::shutdown_type st, + void shutdown(::asio::socket_base::shutdown_type st, std::error_code& e) { try { if (ssl_enabled) { ssl_sock_->shutdown(e); } else { - tcp_sock_->shutdown(asio::ip::tcp::socket::shutdown_send, e); + tcp_sock_->shutdown(::asio::ip::tcp::socket::shutdown_send, e); } } catch (const std::error_code& e) { diff --git a/boost/network/uri/builder.hpp b/boost/network/uri/builder.hpp index c30d1fd86..759ffc65a 100644 --- a/boost/network/uri/builder.hpp +++ b/boost/network/uri/builder.hpp @@ -51,23 +51,23 @@ class builder { builder &host(const string_type &host) { return set_host(host); } - builder &set_host(const asio::ip::address &address) { + builder &set_host(const ::asio::ip::address &address) { uri_.uri_.append(address.to_string()); uri_.parse(); return *this; } - builder &host(const asio::ip::address &host) { return set_host(host); } + builder &host(const ::asio::ip::address &host) { return set_host(host); } - builder &set_host(const asio::ip::address_v4 &address) { + builder &set_host(const ::asio::ip::address_v4 &address) { uri_.uri_.append(address.to_string()); uri_.parse(); return *this; } - builder &host(const asio::ip::address_v4 &host) { return set_host(host); } + builder &host(const ::asio::ip::address_v4 &host) { return set_host(host); } - builder &set_host(const asio::ip::address_v6 &address) { + builder &set_host(const ::asio::ip::address_v6 &address) { uri_.uri_.append("["); uri_.uri_.append(address.to_string()); uri_.uri_.append("]"); @@ -75,7 +75,7 @@ class builder { return *this; } - builder &host(const asio::ip::address_v6 &host) { return set_host(host); } + builder &host(const ::asio::ip::address_v6 &host) { return set_host(host); } builder &set_port(const string_type &port) { uri_.uri_.append(":"); diff --git a/boost/network/utils/thread_pool.hpp b/boost/network/utils/thread_pool.hpp index bea9ab5ad..6ed44b51f 100644 --- a/boost/network/utils/thread_pool.hpp +++ b/boost/network/utils/thread_pool.hpp @@ -19,9 +19,9 @@ namespace boost { namespace network { namespace utils { -typedef std::shared_ptr io_service_ptr; +typedef std::shared_ptr<::asio::io_service> io_service_ptr; typedef std::shared_ptr worker_threads_ptr; -typedef std::shared_ptr sentinel_ptr; +typedef std::shared_ptr<::asio::io_service::work> sentinel_ptr; template struct basic_thread_pool { @@ -55,7 +55,7 @@ struct basic_thread_pool { BOOST_SCOPE_EXIT_END if (!io_service_.get()) { - io_service_.reset(new asio::io_service); + io_service_.reset(new ::asio::io_service); } if (!worker_threads_.get()) { @@ -63,7 +63,7 @@ struct basic_thread_pool { } if (!sentinel_.get()) { - sentinel_.reset(new asio::io_service::work(*io_service_)); + sentinel_.reset(new ::asio::io_service::work(*io_service_)); } for (std::size_t counter = 0; counter < threads_; ++counter) {