diff --git a/CHANGELOG.md b/CHANGELOG.md index 569d4ea9..d6edf790 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +Version 195: + +* net is a namespace alias for boost::asio + +-------------------------------------------------------------------------------- + Version 194: * http::async_read returns the right byte count on error diff --git a/example/advanced/server-flex/advanced_server_flex.cpp b/example/advanced/server-flex/advanced_server_flex.cpp index 4c721459..250c1362 100644 --- a/example/advanced/server-flex/advanced_server_flex.cpp +++ b/example/advanced/server-flex/advanced_server_flex.cpp @@ -38,21 +38,23 @@ #include #include -using tcp = boost::asio::ip::tcp; // from +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from namespace ssl = boost::asio::ssl; // from -namespace http = boost::beast::http; // from -namespace websocket = boost::beast::websocket; // from +using tcp = boost::asio::ip::tcp; // from // Return a reasonable mime type based on the extension of a file. -boost::beast::string_view -mime_type(boost::beast::string_view path) +beast::string_view +mime_type(beast::string_view path) { - using boost::beast::iequals; + using beast::iequals; auto const ext = [&path] { auto const pos = path.rfind("."); - if(pos == boost::beast::string_view::npos) - return boost::beast::string_view{}; + if(pos == beast::string_view::npos) + return beast::string_view{}; return path.substr(pos); }(); if(iequals(ext, ".htm")) return "text/html"; @@ -83,8 +85,8 @@ mime_type(boost::beast::string_view path) // The returned path is normalized for the platform. std::string path_cat( - boost::beast::string_view base, - boost::beast::string_view path) + beast::string_view base, + beast::string_view path) { if(base.empty()) return path.to_string(); @@ -115,13 +117,13 @@ template< class Send> void handle_request( - boost::beast::string_view doc_root, + beast::string_view doc_root, http::request>&& req, Send&& send) { // Returns a bad request response auto const bad_request = - [&req](boost::beast::string_view why) + [&req](beast::string_view why) { http::response res{http::status::bad_request, req.version()}; res.set(http::field::server, BOOST_BEAST_VERSION_STRING); @@ -134,7 +136,7 @@ handle_request( // Returns a not found response auto const not_found = - [&req](boost::beast::string_view target) + [&req](beast::string_view target) { http::response res{http::status::not_found, req.version()}; res.set(http::field::server, BOOST_BEAST_VERSION_STRING); @@ -147,7 +149,7 @@ handle_request( // Returns a server error response auto const server_error = - [&req](boost::beast::string_view what) + [&req](beast::string_view what) { http::response res{http::status::internal_server_error, req.version()}; res.set(http::field::server, BOOST_BEAST_VERSION_STRING); @@ -166,7 +168,7 @@ handle_request( // Request path must be absolute and not contain "..". if( req.target().empty() || req.target()[0] != '/' || - req.target().find("..") != boost::beast::string_view::npos) + req.target().find("..") != beast::string_view::npos) return send(bad_request("Illegal request-target")); // Build the path to the requested file @@ -175,12 +177,12 @@ handle_request( path.append("index.html"); // Attempt to open the file - boost::beast::error_code ec; + beast::error_code ec; http::file_body::value_type body; - body.open(path.c_str(), boost::beast::file_mode::scan, ec); + body.open(path.c_str(), beast::file_mode::scan, ec); // Handle the case where the file doesn't exist - if(ec == boost::system::errc::no_such_file_or_directory) + if(ec == beast::errc::no_such_file_or_directory) return send(not_found(req.target())); // Handle an unknown error @@ -217,7 +219,7 @@ handle_request( // Report a failure void -fail(boost::system::error_code ec, char const* what) +fail(beast::error_code ec, char const* what) { std::cerr << what << ": " << ec.message() << "\n"; } @@ -238,18 +240,18 @@ class websocket_session return static_cast(*this); } - boost::beast::multi_buffer buffer_; + beast::multi_buffer buffer_; char ping_state_ = 0; protected: - boost::asio::strand< - boost::asio::io_context::executor_type> strand_; - boost::asio::steady_timer timer_; + net::strand< + net::io_context::executor_type> strand_; + net::steady_timer timer_; public: // Construct the session explicit - websocket_session(boost::asio::io_context& ioc) + websocket_session(net::io_context& ioc) : strand_(ioc.get_executor()) , timer_(ioc, (std::chrono::steady_clock::time_point::max)()) @@ -276,7 +278,7 @@ public: // Accept the websocket handshake derived().ws().async_accept( req, - boost::asio::bind_executor( + net::bind_executor( strand_, std::bind( &websocket_session::on_accept, @@ -285,10 +287,10 @@ public: } void - on_accept(boost::system::error_code ec) + on_accept(beast::error_code ec) { // Happens when the timer closes the socket - if(ec == boost::asio::error::operation_aborted) + if(ec == net::error::operation_aborted) return; if(ec) @@ -300,9 +302,9 @@ public: // Called when the timer expires. void - on_timer(boost::system::error_code ec) + on_timer(beast::error_code ec) { - if(ec && ec != boost::asio::error::operation_aborted) + if(ec && ec != net::error::operation_aborted) return fail(ec, "timer"); // See if the timer really expired since the deadline may have moved. @@ -320,7 +322,7 @@ public: // Now send the ping derived().ws().async_ping({}, - boost::asio::bind_executor( + net::bind_executor( strand_, std::bind( &websocket_session::on_ping, @@ -340,7 +342,7 @@ public: // Wait on the timer timer_.async_wait( - boost::asio::bind_executor( + net::bind_executor( strand_, std::bind( &websocket_session::on_timer, @@ -361,10 +363,10 @@ public: // Called after a ping is sent. void - on_ping(boost::system::error_code ec) + on_ping(beast::error_code ec) { // Happens when the timer closes the socket - if(ec == boost::asio::error::operation_aborted) + if(ec == net::error::operation_aborted) return; if(ec) @@ -387,7 +389,7 @@ public: void on_control_callback( websocket::frame_type kind, - boost::beast::string_view payload) + beast::string_view payload) { boost::ignore_unused(kind, payload); @@ -401,7 +403,7 @@ public: // Read a message into our buffer derived().ws().async_read( buffer_, - boost::asio::bind_executor( + net::bind_executor( strand_, std::bind( &websocket_session::on_read, @@ -412,13 +414,13 @@ public: void on_read( - boost::system::error_code ec, + beast::error_code ec, std::size_t bytes_transferred) { boost::ignore_unused(bytes_transferred); // Happens when the timer closes the socket - if(ec == boost::asio::error::operation_aborted) + if(ec == net::error::operation_aborted) return; // This indicates that the websocket_session was closed @@ -435,7 +437,7 @@ public: derived().ws().text(derived().ws().got_text()); derived().ws().async_write( buffer_.data(), - boost::asio::bind_executor( + net::bind_executor( strand_, std::bind( &websocket_session::on_write, @@ -446,13 +448,13 @@ public: void on_write( - boost::system::error_code ec, + beast::error_code ec, std::size_t bytes_transferred) { boost::ignore_unused(bytes_transferred); // Happens when the timer closes the socket - if(ec == boost::asio::error::operation_aborted) + if(ec == net::error::operation_aborted) return; if(ec) @@ -518,7 +520,7 @@ public: // Close the WebSocket Connection ws_.async_close( websocket::close_code::normal, - boost::asio::bind_executor( + net::bind_executor( strand_, std::bind( &plain_websocket_session::on_close, @@ -527,10 +529,10 @@ public: } void - on_close(boost::system::error_code ec) + on_close(beast::error_code ec) { // Happens when close times out - if(ec == boost::asio::error::operation_aborted) + if(ec == net::error::operation_aborted) return; if(ec) @@ -545,13 +547,13 @@ class ssl_websocket_session : public websocket_session , public std::enable_shared_from_this { - websocket::stream> ws_; + websocket::stream> ws_; bool eof_ = false; public: // Create the http_session explicit - ssl_websocket_session(boost::beast::ssl_stream stream) + ssl_websocket_session(beast::ssl_stream stream) : websocket_session( stream.get_executor().context()) , ws_(std::move(stream)) @@ -559,7 +561,7 @@ public: } // Called by the base class - websocket::stream>& + websocket::stream>& ws() { return ws_; @@ -588,7 +590,7 @@ public: // Perform the SSL shutdown ws_.next_layer().async_shutdown( - boost::asio::bind_executor( + net::bind_executor( strand_, std::bind( &ssl_websocket_session::on_shutdown, @@ -597,10 +599,10 @@ public: } void - on_shutdown(boost::system::error_code ec) + on_shutdown(beast::error_code ec) { // Happens when the shutdown times out - if(ec == boost::asio::error::operation_aborted) + if(ec == net::error::operation_aborted) return; if(ec) @@ -637,7 +639,7 @@ make_websocket_session( template void make_websocket_session( - boost::beast::ssl_stream stream, + beast::ssl_stream stream, http::request> req) { std::make_shared( @@ -733,7 +735,7 @@ class http_session http::async_write( self_.derived().stream(), msg_, - boost::asio::bind_executor( + net::bind_executor( self_.strand_, std::bind( &http_session::on_write, @@ -758,16 +760,16 @@ class http_session queue queue_; protected: - boost::asio::steady_timer timer_; - boost::asio::strand< - boost::asio::io_context::executor_type> strand_; - boost::beast::flat_buffer buffer_; + net::steady_timer timer_; + net::strand< + net::io_context::executor_type> strand_; + beast::flat_buffer buffer_; public: // Construct the session http_session( - boost::asio::io_context& ioc, - boost::beast::flat_buffer buffer, + net::io_context& ioc, + beast::flat_buffer buffer, std::shared_ptr const& doc_root) : doc_root_(doc_root) , queue_(*this) @@ -793,7 +795,7 @@ public: derived().stream(), buffer_, req_, - boost::asio::bind_executor( + net::bind_executor( strand_, std::bind( &http_session::on_read, @@ -803,9 +805,9 @@ public: // Called when the timer expires. void - on_timer(boost::system::error_code ec) + on_timer(beast::error_code ec) { - if(ec && ec != boost::asio::error::operation_aborted) + if(ec && ec != net::error::operation_aborted) return fail(ec, "timer"); // Check if this has been upgraded to Websocket @@ -818,7 +820,7 @@ public: // Wait on the timer timer_.async_wait( - boost::asio::bind_executor( + net::bind_executor( strand_, std::bind( &http_session::on_timer, @@ -827,10 +829,10 @@ public: } void - on_read(boost::system::error_code ec) + on_read(beast::error_code ec) { // Happens when the timer closes the socket - if(ec == boost::asio::error::operation_aborted) + if(ec == net::error::operation_aborted) return; // This means they closed the connection @@ -862,10 +864,10 @@ public: } void - on_write(boost::system::error_code ec, bool close) + on_write(beast::error_code ec, bool close) { // Happens when the timer closes the socket - if(ec == boost::asio::error::operation_aborted) + if(ec == net::error::operation_aborted) return; if(ec) @@ -893,14 +895,14 @@ class plain_http_session , public std::enable_shared_from_this { tcp::socket socket_; - boost::asio::strand< - boost::asio::io_context::executor_type> strand_; + net::strand< + net::io_context::executor_type> strand_; public: // Create the http_session plain_http_session( tcp::socket socket, - boost::beast::flat_buffer buffer, + beast::flat_buffer buffer, std::shared_ptr const& doc_root) : http_session( socket.get_executor().context(), @@ -931,8 +933,8 @@ public: { // Make sure we run on the strand if(! strand_.running_in_this_thread()) - return boost::asio::post( - boost::asio::bind_executor( + return net::post( + net::bind_executor( strand_, std::bind( &plain_http_session::run, @@ -949,7 +951,7 @@ public: do_eof() { // Send a TCP shutdown - boost::system::error_code ec; + beast::error_code ec; socket_.shutdown(tcp::socket::shutdown_send, ec); // At this point the connection is closed gracefully @@ -959,8 +961,8 @@ public: do_timeout() { // Closing the socket cancels all outstanding operations. They - // will complete with boost::asio::error::operation_aborted - boost::system::error_code ec; + // will complete with net::error::operation_aborted + beast::error_code ec; socket_.shutdown(tcp::socket::shutdown_both, ec); socket_.close(ec); } @@ -971,9 +973,9 @@ class ssl_http_session : public http_session , public std::enable_shared_from_this { - boost::beast::ssl_stream stream_; - boost::asio::strand< - boost::asio::io_context::executor_type> strand_; + beast::ssl_stream stream_; + net::strand< + net::io_context::executor_type> strand_; bool eof_ = false; public: @@ -981,7 +983,7 @@ public: ssl_http_session( tcp::socket socket, ssl::context& ctx, - boost::beast::flat_buffer buffer, + beast::flat_buffer buffer, std::shared_ptr const& doc_root) : http_session( socket.get_executor().context(), @@ -993,14 +995,14 @@ public: } // Called by the base class - boost::beast::ssl_stream& + beast::ssl_stream& stream() { return stream_; } // Called by the base class - boost::beast::ssl_stream + beast::ssl_stream release_stream() { return std::move(stream_); @@ -1012,8 +1014,8 @@ public: { // Make sure we run on the strand if(! strand_.running_in_this_thread()) - return boost::asio::post( - boost::asio::bind_executor( + return net::post( + net::bind_executor( strand_, std::bind( &ssl_http_session::run, @@ -1031,7 +1033,7 @@ public: stream_.async_handshake( ssl::stream_base::server, buffer_.data(), - boost::asio::bind_executor( + net::bind_executor( strand_, std::bind( &ssl_http_session::on_handshake, @@ -1041,11 +1043,11 @@ public: } void on_handshake( - boost::system::error_code ec, + beast::error_code ec, std::size_t bytes_used) { // Happens when the handshake times out - if(ec == boost::asio::error::operation_aborted) + if(ec == net::error::operation_aborted) return; if(ec) @@ -1067,7 +1069,7 @@ public: // Perform the SSL shutdown stream_.async_shutdown( - boost::asio::bind_executor( + net::bind_executor( strand_, std::bind( &ssl_http_session::on_shutdown, @@ -1076,10 +1078,10 @@ public: } void - on_shutdown(boost::system::error_code ec) + on_shutdown(beast::error_code ec) { // Happens when the shutdown times out - if(ec == boost::asio::error::operation_aborted) + if(ec == net::error::operation_aborted) return; if(ec) @@ -1110,10 +1112,10 @@ class detect_session : public std::enable_shared_from_this { tcp::socket socket_; ssl::context& ctx_; - boost::asio::strand< - boost::asio::io_context::executor_type> strand_; + net::strand< + net::io_context::executor_type> strand_; std::shared_ptr doc_root_; - boost::beast::flat_buffer buffer_; + beast::flat_buffer buffer_; public: explicit @@ -1135,7 +1137,7 @@ public: async_detect_ssl( socket_, buffer_, - boost::asio::bind_executor( + net::bind_executor( strand_, std::bind( &detect_session::on_detect, @@ -1146,7 +1148,7 @@ public: } void - on_detect(boost::system::error_code ec, boost::tribool result) + on_detect(beast::error_code ec, boost::tribool result) { if(ec) return fail(ec, "detect"); @@ -1180,7 +1182,7 @@ class listener : public std::enable_shared_from_this public: listener( - boost::asio::io_context& ioc, + net::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint, std::shared_ptr const& doc_root) @@ -1189,7 +1191,7 @@ public: , socket_(ioc) , doc_root_(doc_root) { - boost::system::error_code ec; + beast::error_code ec; // Open the acceptor acceptor_.open(endpoint.protocol(), ec); @@ -1200,7 +1202,7 @@ public: } // Allow address reuse - acceptor_.set_option(boost::asio::socket_base::reuse_address(true), ec); + acceptor_.set_option(net::socket_base::reuse_address(true), ec); if(ec) { fail(ec, "set_option"); @@ -1217,7 +1219,7 @@ public: // Start listening for connections acceptor_.listen( - boost::asio::socket_base::max_listen_connections, ec); + net::socket_base::max_listen_connections, ec); if(ec) { fail(ec, "listen"); @@ -1246,7 +1248,7 @@ public: } void - on_accept(boost::system::error_code ec) + on_accept(beast::error_code ec) { if(ec) { @@ -1279,13 +1281,13 @@ int main(int argc, char* argv[]) " advanced-server-flex 0.0.0.0 8080 . 1\n"; return EXIT_FAILURE; } - auto const address = boost::asio::ip::make_address(argv[1]); + auto const address = net::ip::make_address(argv[1]); auto const port = static_cast(std::atoi(argv[2])); auto const doc_root = std::make_shared(argv[3]); auto const threads = std::max(1, std::atoi(argv[4])); // The io_context is required for all I/O - boost::asio::io_context ioc{threads}; + net::io_context ioc{threads}; // The SSL context is required, and holds certificates ssl::context ctx{ssl::context::sslv23}; @@ -1301,9 +1303,9 @@ int main(int argc, char* argv[]) doc_root)->run(); // Capture SIGINT and SIGTERM to perform a clean shutdown - boost::asio::signal_set signals(ioc, SIGINT, SIGTERM); + net::signal_set signals(ioc, SIGINT, SIGTERM); signals.async_wait( - [&](boost::system::error_code const&, int) + [&](beast::error_code const&, int) { // Stop the `io_context`. This will cause `run()` // to return immediately, eventually destroying the diff --git a/example/advanced/server/advanced_server.cpp b/example/advanced/server/advanced_server.cpp index 14c52e34..c7c38280 100644 --- a/example/advanced/server/advanced_server.cpp +++ b/example/advanced/server/advanced_server.cpp @@ -33,20 +33,22 @@ #include #include +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from using tcp = boost::asio::ip::tcp; // from -namespace http = boost::beast::http; // from -namespace websocket = boost::beast::websocket; // from // Return a reasonable mime type based on the extension of a file. -boost::beast::string_view -mime_type(boost::beast::string_view path) +beast::string_view +mime_type(beast::string_view path) { - using boost::beast::iequals; + using beast::iequals; auto const ext = [&path] { auto const pos = path.rfind("."); - if(pos == boost::beast::string_view::npos) - return boost::beast::string_view{}; + if(pos == beast::string_view::npos) + return beast::string_view{}; return path.substr(pos); }(); if(iequals(ext, ".htm")) return "text/html"; @@ -77,8 +79,8 @@ mime_type(boost::beast::string_view path) // The returned path is normalized for the platform. std::string path_cat( - boost::beast::string_view base, - boost::beast::string_view path) + beast::string_view base, + beast::string_view path) { if(base.empty()) return path.to_string(); @@ -109,13 +111,13 @@ template< class Send> void handle_request( - boost::beast::string_view doc_root, + beast::string_view doc_root, http::request>&& req, Send&& send) { // Returns a bad request response auto const bad_request = - [&req](boost::beast::string_view why) + [&req](beast::string_view why) { http::response res{http::status::bad_request, req.version()}; res.set(http::field::server, BOOST_BEAST_VERSION_STRING); @@ -128,7 +130,7 @@ handle_request( // Returns a not found response auto const not_found = - [&req](boost::beast::string_view target) + [&req](beast::string_view target) { http::response res{http::status::not_found, req.version()}; res.set(http::field::server, BOOST_BEAST_VERSION_STRING); @@ -141,7 +143,7 @@ handle_request( // Returns a server error response auto const server_error = - [&req](boost::beast::string_view what) + [&req](beast::string_view what) { http::response res{http::status::internal_server_error, req.version()}; res.set(http::field::server, BOOST_BEAST_VERSION_STRING); @@ -160,7 +162,7 @@ handle_request( // Request path must be absolute and not contain "..". if( req.target().empty() || req.target()[0] != '/' || - req.target().find("..") != boost::beast::string_view::npos) + req.target().find("..") != beast::string_view::npos) return send(bad_request("Illegal request-target")); // Build the path to the requested file @@ -169,12 +171,12 @@ handle_request( path.append("index.html"); // Attempt to open the file - boost::beast::error_code ec; + beast::error_code ec; http::file_body::value_type body; - body.open(path.c_str(), boost::beast::file_mode::scan, ec); + body.open(path.c_str(), beast::file_mode::scan, ec); // Handle the case where the file doesn't exist - if(ec == boost::system::errc::no_such_file_or_directory) + if(ec == beast::errc::no_such_file_or_directory) return send(not_found(req.target())); // Handle an unknown error @@ -211,7 +213,7 @@ handle_request( // Report a failure void -fail(boost::system::error_code ec, char const* what) +fail(beast::error_code ec, char const* what) { std::cerr << what << ": " << ec.message() << "\n"; } @@ -220,10 +222,10 @@ fail(boost::system::error_code ec, char const* what) class websocket_session : public std::enable_shared_from_this { websocket::stream ws_; - boost::asio::strand< - boost::asio::io_context::executor_type> strand_; - boost::asio::steady_timer timer_; - boost::beast::multi_buffer buffer_; + net::strand< + net::io_context::executor_type> strand_; + net::steady_timer timer_; + beast::multi_buffer buffer_; char ping_state_ = 0; public: @@ -261,7 +263,7 @@ public: // Accept the websocket handshake ws_.async_accept( req, - boost::asio::bind_executor( + net::bind_executor( strand_, std::bind( &websocket_session::on_accept, @@ -270,10 +272,10 @@ public: } void - on_accept(boost::system::error_code ec) + on_accept(beast::error_code ec) { // Happens when the timer closes the socket - if(ec == boost::asio::error::operation_aborted) + if(ec == net::error::operation_aborted) return; if(ec) @@ -285,9 +287,9 @@ public: // Called when the timer expires. void - on_timer(boost::system::error_code ec) + on_timer(beast::error_code ec) { - if(ec && ec != boost::asio::error::operation_aborted) + if(ec && ec != net::error::operation_aborted) return fail(ec, "timer"); // See if the timer really expired since the deadline may have moved. @@ -305,7 +307,7 @@ public: // Now send the ping ws_.async_ping({}, - boost::asio::bind_executor( + net::bind_executor( strand_, std::bind( &websocket_session::on_ping, @@ -319,7 +321,7 @@ public: // we never got back a control frame, so close. // Closing the socket cancels all outstanding operations. They - // will complete with boost::asio::error::operation_aborted + // will complete with net::error::operation_aborted ws_.next_layer().shutdown(tcp::socket::shutdown_both, ec); ws_.next_layer().close(ec); return; @@ -328,7 +330,7 @@ public: // Wait on the timer timer_.async_wait( - boost::asio::bind_executor( + net::bind_executor( strand_, std::bind( &websocket_session::on_timer, @@ -349,10 +351,10 @@ public: // Called after a ping is sent. void - on_ping(boost::system::error_code ec) + on_ping(beast::error_code ec) { // Happens when the timer closes the socket - if(ec == boost::asio::error::operation_aborted) + if(ec == net::error::operation_aborted) return; if(ec) @@ -375,7 +377,7 @@ public: void on_control_callback( websocket::frame_type kind, - boost::beast::string_view payload) + beast::string_view payload) { boost::ignore_unused(kind, payload); @@ -389,7 +391,7 @@ public: // Read a message into our buffer ws_.async_read( buffer_, - boost::asio::bind_executor( + net::bind_executor( strand_, std::bind( &websocket_session::on_read, @@ -400,13 +402,13 @@ public: void on_read( - boost::system::error_code ec, + beast::error_code ec, std::size_t bytes_transferred) { boost::ignore_unused(bytes_transferred); // Happens when the timer closes the socket - if(ec == boost::asio::error::operation_aborted) + if(ec == net::error::operation_aborted) return; // This indicates that the websocket_session was closed @@ -423,7 +425,7 @@ public: ws_.text(ws_.got_text()); ws_.async_write( buffer_.data(), - boost::asio::bind_executor( + net::bind_executor( strand_, std::bind( &websocket_session::on_write, @@ -434,13 +436,13 @@ public: void on_write( - boost::system::error_code ec, + beast::error_code ec, std::size_t bytes_transferred) { boost::ignore_unused(bytes_transferred); // Happens when the timer closes the socket - if(ec == boost::asio::error::operation_aborted) + if(ec == net::error::operation_aborted) return; if(ec) @@ -530,7 +532,7 @@ class http_session : public std::enable_shared_from_this http::async_write( self_.socket_, msg_, - boost::asio::bind_executor( + net::bind_executor( self_.strand_, std::bind( &http_session::on_write, @@ -551,10 +553,10 @@ class http_session : public std::enable_shared_from_this }; tcp::socket socket_; - boost::asio::strand< - boost::asio::io_context::executor_type> strand_; - boost::asio::steady_timer timer_; - boost::beast::flat_buffer buffer_; + net::strand< + net::io_context::executor_type> strand_; + net::steady_timer timer_; + beast::flat_buffer buffer_; std::shared_ptr doc_root_; http::request req_; queue queue_; @@ -580,8 +582,8 @@ public: { // Make sure we run on the strand if(! strand_.running_in_this_thread()) - return boost::asio::post( - boost::asio::bind_executor( + return net::post( + net::bind_executor( strand_, std::bind( &http_session::run, @@ -606,7 +608,7 @@ public: // Read a request http::async_read(socket_, buffer_, req_, - boost::asio::bind_executor( + net::bind_executor( strand_, std::bind( &http_session::on_read, @@ -616,9 +618,9 @@ public: // Called when the timer expires. void - on_timer(boost::system::error_code ec) + on_timer(beast::error_code ec) { - if(ec && ec != boost::asio::error::operation_aborted) + if(ec && ec != net::error::operation_aborted) return fail(ec, "timer"); // Check if this has been upgraded to Websocket @@ -629,7 +631,7 @@ public: if(timer_.expiry() <= std::chrono::steady_clock::now()) { // Closing the socket cancels all outstanding operations. They - // will complete with boost::asio::error::operation_aborted + // will complete with net::error::operation_aborted socket_.shutdown(tcp::socket::shutdown_both, ec); socket_.close(ec); return; @@ -637,7 +639,7 @@ public: // Wait on the timer timer_.async_wait( - boost::asio::bind_executor( + net::bind_executor( strand_, std::bind( &http_session::on_timer, @@ -646,10 +648,10 @@ public: } void - on_read(boost::system::error_code ec) + on_read(beast::error_code ec) { // Happens when the timer closes the socket - if(ec == boost::asio::error::operation_aborted) + if(ec == net::error::operation_aborted) return; // This means they closed the connection @@ -681,10 +683,10 @@ public: } void - on_write(boost::system::error_code ec, bool close) + on_write(beast::error_code ec, bool close) { // Happens when the timer closes the socket - if(ec == boost::asio::error::operation_aborted) + if(ec == net::error::operation_aborted) return; if(ec) @@ -709,7 +711,7 @@ public: do_close() { // Send a TCP shutdown - boost::system::error_code ec; + beast::error_code ec; socket_.shutdown(tcp::socket::shutdown_send, ec); // At this point the connection is closed gracefully @@ -727,14 +729,14 @@ class listener : public std::enable_shared_from_this public: listener( - boost::asio::io_context& ioc, + net::io_context& ioc, tcp::endpoint endpoint, std::shared_ptr const& doc_root) : acceptor_(ioc) , socket_(ioc) , doc_root_(doc_root) { - boost::system::error_code ec; + beast::error_code ec; // Open the acceptor acceptor_.open(endpoint.protocol(), ec); @@ -745,7 +747,7 @@ public: } // Allow address reuse - acceptor_.set_option(boost::asio::socket_base::reuse_address(true), ec); + acceptor_.set_option(net::socket_base::reuse_address(true), ec); if(ec) { fail(ec, "set_option"); @@ -762,7 +764,7 @@ public: // Start listening for connections acceptor_.listen( - boost::asio::socket_base::max_listen_connections, ec); + net::socket_base::max_listen_connections, ec); if(ec) { fail(ec, "listen"); @@ -791,7 +793,7 @@ public: } void - on_accept(boost::system::error_code ec) + on_accept(beast::error_code ec) { if(ec) { @@ -823,13 +825,13 @@ int main(int argc, char* argv[]) " advanced-server 0.0.0.0 8080 . 1\n"; return EXIT_FAILURE; } - auto const address = boost::asio::ip::make_address(argv[1]); + auto const address = net::ip::make_address(argv[1]); auto const port = static_cast(std::atoi(argv[2])); auto const doc_root = std::make_shared(argv[3]); auto const threads = std::max(1, std::atoi(argv[4])); // The io_context is required for all I/O - boost::asio::io_context ioc{threads}; + net::io_context ioc{threads}; // Create and launch a listening port std::make_shared( @@ -838,9 +840,9 @@ int main(int argc, char* argv[]) doc_root)->run(); // Capture SIGINT and SIGTERM to perform a clean shutdown - boost::asio::signal_set signals(ioc, SIGINT, SIGTERM); + net::signal_set signals(ioc, SIGINT, SIGTERM); signals.async_wait( - [&](boost::system::error_code const&, int) + [&](beast::error_code const&, int) { // Stop the `io_context`. This will cause `run()` // to return immediately, eventually destroying the diff --git a/example/cppcon2018/beast.hpp b/example/cppcon2018/beast.hpp index d24e24a5..54e12597 100644 --- a/example/cppcon2018/beast.hpp +++ b/example/cppcon2018/beast.hpp @@ -12,8 +12,8 @@ #include -namespace beast = boost::beast; -namespace http = boost::beast::http; // from -namespace websocket = boost::beast::websocket; // from +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from #endif diff --git a/example/cppcon2018/http_session.cpp b/example/cppcon2018/http_session.cpp index ac4f58ff..f20df10c 100644 --- a/example/cppcon2018/http_session.cpp +++ b/example/cppcon2018/http_session.cpp @@ -17,15 +17,15 @@ //------------------------------------------------------------------------------ // Return a reasonable mime type based on the extension of a file. -boost::beast::string_view -mime_type(boost::beast::string_view path) +beast::string_view +mime_type(beast::string_view path) { - using boost::beast::iequals; + using beast::iequals; auto const ext = [&path] { auto const pos = path.rfind("."); - if(pos == boost::beast::string_view::npos) - return boost::beast::string_view{}; + if(pos == beast::string_view::npos) + return beast::string_view{}; return path.substr(pos); }(); if(iequals(ext, ".htm")) return "text/html"; @@ -56,8 +56,8 @@ mime_type(boost::beast::string_view path) // The returned path is normalized for the platform. std::string path_cat( - boost::beast::string_view base, - boost::beast::string_view path) + beast::string_view base, + beast::string_view path) { if(base.empty()) return path.to_string(); @@ -88,13 +88,13 @@ template< class Send> void handle_request( - boost::beast::string_view doc_root, + beast::string_view doc_root, http::request>&& req, Send&& send) { // Returns a bad request response auto const bad_request = - [&req](boost::beast::string_view why) + [&req](beast::string_view why) { http::response res{http::status::bad_request, req.version()}; res.set(http::field::server, BOOST_BEAST_VERSION_STRING); @@ -107,7 +107,7 @@ handle_request( // Returns a not found response auto const not_found = - [&req](boost::beast::string_view target) + [&req](beast::string_view target) { http::response res{http::status::not_found, req.version()}; res.set(http::field::server, BOOST_BEAST_VERSION_STRING); @@ -120,7 +120,7 @@ handle_request( // Returns a server error response auto const server_error = - [&req](boost::beast::string_view what) + [&req](beast::string_view what) { http::response res{http::status::internal_server_error, req.version()}; res.set(http::field::server, BOOST_BEAST_VERSION_STRING); @@ -139,7 +139,7 @@ handle_request( // Request path must be absolute and not contain "..". if( req.target().empty() || req.target()[0] != '/' || - req.target().find("..") != boost::beast::string_view::npos) + req.target().find("..") != beast::string_view::npos) return send(bad_request("Illegal request-target")); // Build the path to the requested file @@ -148,9 +148,9 @@ handle_request( path.append("index.html"); // Attempt to open the file - boost::beast::error_code ec; + beast::error_code ec; http::file_body::value_type body; - body.open(path.c_str(), boost::beast::file_mode::scan, ec); + body.open(path.c_str(), beast::file_mode::scan, ec); // Handle the case where the file doesn't exist if(ec == boost::system::errc::no_such_file_or_directory) @@ -213,7 +213,7 @@ run() // Report a failure void http_session:: -fail(error_code ec, char const* what) +fail(beast::error_code ec, char const* what) { // Don't report on canceled operations if(ec == net::error::operation_aborted) @@ -239,7 +239,7 @@ operator()(http::message&& msg) const http::async_write( self_.socket_, *sp, - [self, sp](error_code ec, std::size_t bytes) + [self, sp](beast::error_code ec, std::size_t bytes) { self->on_write(ec, bytes, sp->need_eof()); }); @@ -247,7 +247,7 @@ operator()(http::message&& msg) const void http_session:: -on_read(error_code ec, std::size_t) +on_read(beast::error_code ec, std::size_t) { // This means they closed the connection if(ec == http::error::end_of_stream) @@ -291,7 +291,7 @@ on_read(error_code ec, std::size_t) // Write the response http::async_write(this->socket_, *sp, [self = shared_from_this(), sp]( - error_code ec, std::size_t bytes) + beast::error_code ec, std::size_t bytes) { self->on_write(ec, bytes, sp->need_eof()); }); @@ -300,7 +300,7 @@ on_read(error_code ec, std::size_t) auto self = shared_from_this(); http::async_write(this->socket_, *sp, [self, sp]( - error_code ec, std::size_t bytes) + beast::error_code ec, std::size_t bytes) { self->on_write(ec, bytes, sp->need_eof()); }); @@ -321,7 +321,7 @@ on_read(error_code ec, std::size_t) void http_session:: -on_write(error_code ec, std::size_t, bool close) +on_write(beast::error_code ec, std::size_t, bool close) { // Handle the error, if any if(ec) diff --git a/example/cppcon2018/http_session.hpp b/example/cppcon2018/http_session.hpp index 530d2fa8..d40ab87f 100644 --- a/example/cppcon2018/http_session.hpp +++ b/example/cppcon2018/http_session.hpp @@ -40,10 +40,9 @@ class http_session : public std::enable_shared_from_this operator()(http::message&& msg) const; }; - void fail(error_code ec, char const* what); - void on_read(error_code ec, std::size_t); - void on_write( - error_code ec, std::size_t, bool close); + void fail(beast::error_code ec, char const* what); + void on_read(beast::error_code ec, std::size_t); + void on_write(beast::error_code ec, std::size_t, bool close); public: http_session( diff --git a/example/cppcon2018/listener.cpp b/example/cppcon2018/listener.cpp index cca4b320..1f6ab30b 100644 --- a/example/cppcon2018/listener.cpp +++ b/example/cppcon2018/listener.cpp @@ -20,7 +20,7 @@ listener( , socket_(ioc) , state_(state) { - error_code ec; + beast::error_code ec; // Open the acceptor acceptor_.open(endpoint.protocol(), ec); @@ -72,7 +72,7 @@ run() // Report a failure void listener:: -fail(error_code ec, char const* what) +fail(beast::error_code ec, char const* what) { // Don't report on canceled operations if(ec == net::error::operation_aborted) @@ -83,7 +83,7 @@ fail(error_code ec, char const* what) // Handle a connection void listener:: -on_accept(error_code ec) +on_accept(beast::error_code ec) { if(ec) return fail(ec, "accept"); diff --git a/example/cppcon2018/listener.hpp b/example/cppcon2018/listener.hpp index 3ee1a898..47d86ce4 100644 --- a/example/cppcon2018/listener.hpp +++ b/example/cppcon2018/listener.hpp @@ -10,6 +10,7 @@ #ifndef CPPCON2018_LISTENER_HPP #define CPPCON2018_LISTENER_HPP +#include "beast.hpp" #include "net.hpp" #include #include @@ -24,8 +25,8 @@ class listener : public std::enable_shared_from_this tcp::socket socket_; std::shared_ptr state_; - void fail(error_code ec, char const* what); - void on_accept(error_code ec); + void fail(beast::error_code ec, char const* what); + void on_accept(beast::error_code ec); public: listener( diff --git a/example/cppcon2018/net.hpp b/example/cppcon2018/net.hpp index 4c925d05..4879aa17 100644 --- a/example/cppcon2018/net.hpp +++ b/example/cppcon2018/net.hpp @@ -12,8 +12,7 @@ #include -namespace net = boost::asio; // namespace asio -using tcp = net::ip::tcp; // from -using error_code = boost::system::error_code; // from +namespace net = boost::asio; // from +using tcp = boost::asio::ip::tcp; // from #endif diff --git a/example/cppcon2018/websocket_session.cpp b/example/cppcon2018/websocket_session.cpp index 55d0c4e0..e929c057 100644 --- a/example/cppcon2018/websocket_session.cpp +++ b/example/cppcon2018/websocket_session.cpp @@ -27,7 +27,7 @@ websocket_session:: void websocket_session:: -fail(error_code ec, char const* what) +fail(beast::error_code ec, char const* what) { // Don't report these if( ec == net::error::operation_aborted || @@ -39,7 +39,7 @@ fail(error_code ec, char const* what) void websocket_session:: -on_accept(error_code ec) +on_accept(beast::error_code ec) { // Handle the error, if any if(ec) @@ -60,7 +60,7 @@ on_accept(error_code ec) void websocket_session:: -on_read(error_code ec, std::size_t) +on_read(beast::error_code ec, std::size_t) { // Handle the error, if any if(ec) @@ -105,7 +105,7 @@ send(std::shared_ptr const& ss) void websocket_session:: -on_write(error_code ec, std::size_t) +on_write(beast::error_code ec, std::size_t) { // Handle the error, if any if(ec) diff --git a/example/cppcon2018/websocket_session.hpp b/example/cppcon2018/websocket_session.hpp index a8cd5be9..9b5e71a1 100644 --- a/example/cppcon2018/websocket_session.hpp +++ b/example/cppcon2018/websocket_session.hpp @@ -31,10 +31,10 @@ class websocket_session : public std::enable_shared_from_this std::shared_ptr state_; std::vector> queue_; - void fail(error_code ec, char const* what); - void on_accept(error_code ec); - void on_read(error_code ec, std::size_t bytes_transferred); - void on_write(error_code ec, std::size_t bytes_transferred); + void fail(beast::error_code ec, char const* what); + void on_accept(beast::error_code ec); + void on_read(beast::error_code ec, std::size_t bytes_transferred); + void on_write(beast::error_code ec, std::size_t bytes_transferred); public: websocket_session( diff --git a/example/http/client/async-ssl/http_client_async_ssl.cpp b/example/http/client/async-ssl/http_client_async_ssl.cpp index 34c05683..889a4da0 100644 --- a/example/http/client/async-ssl/http_client_async_ssl.cpp +++ b/example/http/client/async-ssl/http_client_async_ssl.cpp @@ -28,15 +28,17 @@ #include #include -using tcp = boost::asio::ip::tcp; // from +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from namespace ssl = boost::asio::ssl; // from -namespace http = boost::beast::http; // from +using tcp = boost::asio::ip::tcp; // from //------------------------------------------------------------------------------ // Report a failure void -fail(boost::system::error_code ec, char const* what) +fail(beast::error_code ec, char const* what) { std::cerr << what << ": " << ec.message() << "\n"; } @@ -46,14 +48,14 @@ class session : public std::enable_shared_from_this { tcp::resolver resolver_; ssl::stream stream_; - boost::beast::flat_buffer buffer_; // (Must persist between reads) + beast::flat_buffer buffer_; // (Must persist between reads) http::request req_; http::response res_; public: // Resolver and stream require an io_context explicit - session(boost::asio::io_context& ioc, ssl::context& ctx) + session(net::io_context& ioc, ssl::context& ctx) : resolver_(ioc) , stream_(ioc, ctx) { @@ -70,7 +72,7 @@ public: // Set SNI Hostname (many hosts need this to handshake successfully) if(! SSL_set_tlsext_host_name(stream_.native_handle(), host)) { - boost::system::error_code ec{static_cast(::ERR_get_error()), boost::asio::error::get_ssl_category()}; + beast::error_code ec{static_cast(::ERR_get_error()), net::error::get_ssl_category()}; std::cerr << ec.message() << "\n"; return; } @@ -95,14 +97,14 @@ public: void on_resolve( - boost::system::error_code ec, + beast::error_code ec, tcp::resolver::results_type results) { if(ec) return fail(ec, "resolve"); // Make the connection on the IP address we get from a lookup - boost::asio::async_connect( + net::async_connect( stream_.next_layer(), results.begin(), results.end(), @@ -113,7 +115,7 @@ public: } void - on_connect(boost::system::error_code ec) + on_connect(beast::error_code ec) { if(ec) return fail(ec, "connect"); @@ -128,7 +130,7 @@ public: } void - on_handshake(boost::system::error_code ec) + on_handshake(beast::error_code ec) { if(ec) return fail(ec, "handshake"); @@ -144,7 +146,7 @@ public: void on_write( - boost::system::error_code ec, + beast::error_code ec, std::size_t bytes_transferred) { boost::ignore_unused(bytes_transferred); @@ -163,7 +165,7 @@ public: void on_read( - boost::system::error_code ec, + beast::error_code ec, std::size_t bytes_transferred) { boost::ignore_unused(bytes_transferred); @@ -183,9 +185,9 @@ public: } void - on_shutdown(boost::system::error_code ec) + on_shutdown(beast::error_code ec) { - if(ec == boost::asio::error::eof) + if(ec == net::error::eof) { // Rationale: // http://stackoverflow.com/questions/25587403/boost-asio-ssl-async-shutdown-always-finishes-with-an-error @@ -218,7 +220,7 @@ int main(int argc, char** argv) int version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; // The io_context is required for all I/O - boost::asio::io_context ioc; + net::io_context ioc; // The SSL context is required, and holds certificates ssl::context ctx{ssl::context::sslv23_client}; diff --git a/example/http/client/async/http_client_async.cpp b/example/http/client/async/http_client_async.cpp index ec9fc09e..9eec2a1a 100644 --- a/example/http/client/async/http_client_async.cpp +++ b/example/http/client/async/http_client_async.cpp @@ -24,14 +24,16 @@ #include #include +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from using tcp = boost::asio::ip::tcp; // from -namespace http = boost::beast::http; // from //------------------------------------------------------------------------------ // Report a failure void -fail(boost::system::error_code ec, char const* what) +fail(beast::error_code ec, char const* what) { std::cerr << what << ": " << ec.message() << "\n"; } @@ -41,14 +43,14 @@ class session : public std::enable_shared_from_this { tcp::resolver resolver_; tcp::socket socket_; - boost::beast::flat_buffer buffer_; // (Must persist between reads) + beast::flat_buffer buffer_; // (Must persist between reads) http::request req_; http::response res_; public: // Resolver and socket require an io_context explicit - session(boost::asio::io_context& ioc) + session(net::io_context& ioc) : resolver_(ioc) , socket_(ioc) { @@ -82,14 +84,14 @@ public: void on_resolve( - boost::system::error_code ec, + beast::error_code ec, tcp::resolver::results_type results) { if(ec) return fail(ec, "resolve"); // Make the connection on the IP address we get from a lookup - boost::asio::async_connect( + net::async_connect( socket_, results.begin(), results.end(), @@ -100,7 +102,7 @@ public: } void - on_connect(boost::system::error_code ec) + on_connect(beast::error_code ec) { if(ec) return fail(ec, "connect"); @@ -116,7 +118,7 @@ public: void on_write( - boost::system::error_code ec, + beast::error_code ec, std::size_t bytes_transferred) { boost::ignore_unused(bytes_transferred); @@ -135,7 +137,7 @@ public: void on_read( - boost::system::error_code ec, + beast::error_code ec, std::size_t bytes_transferred) { boost::ignore_unused(bytes_transferred); @@ -150,7 +152,7 @@ public: socket_.shutdown(tcp::socket::shutdown_both, ec); // not_connected happens sometimes so don't bother reporting it. - if(ec && ec != boost::system::errc::not_connected) + if(ec && ec != beast::errc::not_connected) return fail(ec, "shutdown"); // If we get here then the connection is closed gracefully @@ -177,7 +179,7 @@ int main(int argc, char** argv) int version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; // The io_context is required for all I/O - boost::asio::io_context ioc; + net::io_context ioc; // Launch the asynchronous operation std::make_shared(ioc)->run(host, port, target, version); diff --git a/example/http/client/coro-ssl/http_client_coro_ssl.cpp b/example/http/client/coro-ssl/http_client_coro_ssl.cpp index 24fce733..47e876ac 100644 --- a/example/http/client/coro-ssl/http_client_coro_ssl.cpp +++ b/example/http/client/coro-ssl/http_client_coro_ssl.cpp @@ -28,15 +28,17 @@ #include #include -using tcp = boost::asio::ip::tcp; // from +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from namespace ssl = boost::asio::ssl; // from -namespace http = boost::beast::http; // from +using tcp = boost::asio::ip::tcp; // from //------------------------------------------------------------------------------ // Report a failure void -fail(boost::system::error_code ec, char const* what) +fail(beast::error_code ec, char const* what) { std::cerr << what << ": " << ec.message() << "\n"; } @@ -48,11 +50,11 @@ do_session( std::string const& port, std::string const& target, int version, - boost::asio::io_context& ioc, + net::io_context& ioc, ssl::context& ctx, - boost::asio::yield_context yield) + net::yield_context yield) { - boost::system::error_code ec; + beast::error_code ec; // These objects perform our I/O tcp::resolver resolver{ioc}; @@ -61,7 +63,7 @@ do_session( // Set SNI Hostname (many hosts need this to handshake successfully) if(! SSL_set_tlsext_host_name(stream.native_handle(), host.c_str())) { - ec.assign(static_cast(::ERR_get_error()), boost::asio::error::get_ssl_category()); + ec.assign(static_cast(::ERR_get_error()), net::error::get_ssl_category()); std::cerr << ec.message() << "\n"; return; } @@ -72,7 +74,7 @@ do_session( return fail(ec, "resolve"); // Make the connection on the IP address we get from a lookup - boost::asio::async_connect(stream.next_layer(), results.begin(), results.end(), yield[ec]); + net::async_connect(stream.next_layer(), results.begin(), results.end(), yield[ec]); if(ec) return fail(ec, "connect"); @@ -92,7 +94,7 @@ do_session( return fail(ec, "write"); // This buffer is used for reading and must be persisted - boost::beast::flat_buffer b; + beast::flat_buffer b; // Declare a container to hold the response http::response res; @@ -107,7 +109,7 @@ do_session( // Gracefully close the stream stream.async_shutdown(yield[ec]); - if(ec == boost::asio::error::eof) + if(ec == net::error::eof) { // Rationale: // http://stackoverflow.com/questions/25587403/boost-asio-ssl-async-shutdown-always-finishes-with-an-error @@ -139,7 +141,7 @@ int main(int argc, char** argv) int version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; // The io_context is required for all I/O - boost::asio::io_context ioc; + net::io_context ioc; // The SSL context is required, and holds certificates ssl::context ctx{ssl::context::sslv23_client}; @@ -151,7 +153,7 @@ int main(int argc, char** argv) ctx.set_verify_mode(ssl::verify_peer); // Launch the asynchronous operation - boost::asio::spawn(ioc, std::bind( + net::spawn(ioc, std::bind( &do_session, std::string(host), std::string(port), diff --git a/example/http/client/coro/http_client_coro.cpp b/example/http/client/coro/http_client_coro.cpp index f07498e3..8448b9cb 100644 --- a/example/http/client/coro/http_client_coro.cpp +++ b/example/http/client/coro/http_client_coro.cpp @@ -24,14 +24,16 @@ #include #include +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from using tcp = boost::asio::ip::tcp; // from -namespace http = boost::beast::http; // from //------------------------------------------------------------------------------ // Report a failure void -fail(boost::system::error_code ec, char const* what) +fail(beast::error_code ec, char const* what) { std::cerr << what << ": " << ec.message() << "\n"; } @@ -43,10 +45,10 @@ do_session( std::string const& port, std::string const& target, int version, - boost::asio::io_context& ioc, - boost::asio::yield_context yield) + net::io_context& ioc, + net::yield_context yield) { - boost::system::error_code ec; + beast::error_code ec; // These objects perform our I/O tcp::resolver resolver{ioc}; @@ -58,7 +60,7 @@ do_session( return fail(ec, "resolve"); // Make the connection on the IP address we get from a lookup - boost::asio::async_connect(socket, results.begin(), results.end(), yield[ec]); + net::async_connect(socket, results.begin(), results.end(), yield[ec]); if(ec) return fail(ec, "connect"); @@ -73,7 +75,7 @@ do_session( return fail(ec, "write"); // This buffer is used for reading and must be persisted - boost::beast::flat_buffer b; + beast::flat_buffer b; // Declare a container to hold the response http::response res; @@ -92,7 +94,7 @@ do_session( // not_connected happens sometimes // so don't bother reporting it. // - if(ec && ec != boost::system::errc::not_connected) + if(ec && ec != beast::errc::not_connected) return fail(ec, "shutdown"); // If we get here then the connection is closed gracefully @@ -118,10 +120,10 @@ int main(int argc, char** argv) int version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; // The io_context is required for all I/O - boost::asio::io_context ioc; + net::io_context ioc; // Launch the asynchronous operation - boost::asio::spawn(ioc, std::bind( + net::spawn(ioc, std::bind( &do_session, std::string(host), std::string(port), diff --git a/example/http/client/crawl/http_crawl.cpp b/example/http/client/crawl/http_crawl.cpp index bb620f1d..3be4e8f6 100644 --- a/example/http/client/crawl/http_crawl.cpp +++ b/example/http/client/crawl/http_crawl.cpp @@ -35,24 +35,26 @@ #include #include -using tcp = boost::asio::ip::tcp; // from -namespace http = boost::beast::http; // from namespace chrono = std::chrono; // from +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +using tcp = net::ip::tcp; // from //------------------------------------------------------------------------------ // This structure aggregates statistics on all the sites class crawl_report { - boost::asio::io_context& ioc_; - boost::asio::strand< - boost::asio::io_context::executor_type> strand_; + net::io_context& ioc_; + net::strand< + net::io_context::executor_type> strand_; std::atomic index_; std::vector const& hosts_; std::size_t count_ = 0; public: - crawl_report(boost::asio::io_context& ioc) + crawl_report(net::io_context& ioc) : ioc_(ioc) , strand_(ioc_.get_executor()) , index_(0) @@ -66,7 +68,7 @@ public: void aggregate(F const& f) { - boost::asio::post( + net::post( strand_, [&, f] { @@ -150,10 +152,10 @@ class worker : public std::enable_shared_from_this crawl_report& report_; tcp::resolver resolver_; tcp::socket socket_; - boost::asio::steady_timer timer_; - boost::asio::strand< - boost::asio::io_context::executor_type> strand_; - boost::beast::flat_buffer buffer_; // (Must persist between reads) + net::steady_timer timer_; + net::strand< + net::io_context::executor_type> strand_; + beast::flat_buffer buffer_; // (Must persist between reads) http::request req_; http::response res_; @@ -163,7 +165,7 @@ public: // Resolver and socket require an io_context worker( crawl_report& report, - boost::asio::io_context& ioc) + net::io_context& ioc) : report_(report) , resolver_(ioc) , socket_(ioc) @@ -190,9 +192,9 @@ public: } void - on_timer(boost::system::error_code ec) + on_timer(beast::error_code ec) { - if(ec && ec != boost::asio::error::operation_aborted) + if(ec && ec != net::error::operation_aborted) { // Should never happen report_.aggregate( @@ -213,7 +215,7 @@ public: // Wait on the timer timer_.async_wait( - boost::asio::bind_executor( + net::bind_executor( strand_, std::bind( &worker::on_timer, @@ -245,7 +247,7 @@ public: resolver_.async_resolve( host, "http", - boost::asio::bind_executor( + net::bind_executor( strand_, std::bind( &worker::on_resolve, @@ -256,7 +258,7 @@ public: void on_resolve( - boost::system::error_code ec, + beast::error_code ec, tcp::resolver::results_type results) { if(ec) @@ -273,11 +275,11 @@ public: timer_.expires_after(chrono::seconds(timeout)); // Make the connection on the IP address we get from a lookup - boost::asio::async_connect( + net::async_connect( socket_, results.begin(), results.end(), - boost::asio::bind_executor( + net::bind_executor( strand_, std::bind( &worker::on_connect, @@ -286,7 +288,7 @@ public: } void - on_connect(boost::system::error_code ec) + on_connect(beast::error_code ec) { if(ec) { @@ -305,7 +307,7 @@ public: http::async_write( socket_, req_, - boost::asio::bind_executor( + net::bind_executor( strand_, std::bind( &worker::on_write, @@ -316,7 +318,7 @@ public: void on_write( - boost::system::error_code ec, + beast::error_code ec, std::size_t bytes_transferred) { boost::ignore_unused(bytes_transferred); @@ -339,7 +341,7 @@ public: socket_, buffer_, res_, - boost::asio::bind_executor( + net::bind_executor( strand_, std::bind( &worker::on_read, @@ -350,7 +352,7 @@ public: void on_read( - boost::system::error_code ec, + beast::error_code ec, std::size_t bytes_transferred) { boost::ignore_unused(bytes_transferred); @@ -418,10 +420,10 @@ int main(int argc, char* argv[]) auto const threads = std::max(1, std::atoi(argv[1])); // The io_context is required for all I/O - boost::asio::io_context ioc{1}; + net::io_context ioc{1}; // The work keeps io_context::run from returning - auto work = boost::asio::make_work_guard(ioc); + auto work = net::make_work_guard(ioc); // The report holds the aggregated statistics crawl_report report{ioc}; @@ -439,7 +441,7 @@ int main(int argc, char* argv[]) // the asio resolver simulates asynchronous operation using // a dedicated worker thread per io_context, and we want to // do a lot of name resolutions in parallel. - boost::asio::io_context ioc{1}; + net::io_context ioc{1}; std::make_shared(report, ioc)->run(); ioc.run(); }); diff --git a/example/http/client/sync-ssl/http_client_sync_ssl.cpp b/example/http/client/sync-ssl/http_client_sync_ssl.cpp index c3c60371..f0ed8cef 100644 --- a/example/http/client/sync-ssl/http_client_sync_ssl.cpp +++ b/example/http/client/sync-ssl/http_client_sync_ssl.cpp @@ -26,9 +26,11 @@ #include #include -using tcp = boost::asio::ip::tcp; // from -namespace ssl = boost::asio::ssl; // from -namespace http = boost::beast::http; // from +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +namespace ssl = net::ssl; // from +using tcp = net::ip::tcp; // from // Performs an HTTP GET and prints the response int main(int argc, char** argv) @@ -51,7 +53,7 @@ int main(int argc, char** argv) int version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; // The io_context is required for all I/O - boost::asio::io_context ioc; + net::io_context ioc; // The SSL context is required, and holds certificates ssl::context ctx{ssl::context::sslv23_client}; @@ -69,15 +71,15 @@ int main(int argc, char** argv) // Set SNI Hostname (many hosts need this to handshake successfully) if(! SSL_set_tlsext_host_name(stream.native_handle(), host)) { - boost::system::error_code ec{static_cast(::ERR_get_error()), boost::asio::error::get_ssl_category()}; - throw boost::system::system_error{ec}; + beast::error_code ec{static_cast(::ERR_get_error()), net::error::get_ssl_category()}; + throw beast::system_error{ec}; } // Look up the domain name auto const results = resolver.resolve(host, port); // Make the connection on the IP address we get from a lookup - boost::asio::connect(stream.next_layer(), results.begin(), results.end()); + net::connect(stream.next_layer(), results.begin(), results.end()); // Perform the SSL handshake stream.handshake(ssl::stream_base::client); @@ -91,7 +93,7 @@ int main(int argc, char** argv) http::write(stream, req); // This buffer is used for reading and must be persisted - boost::beast::flat_buffer buffer; + beast::flat_buffer buffer; // Declare a container to hold the response http::response res; @@ -103,16 +105,16 @@ int main(int argc, char** argv) std::cout << res << std::endl; // Gracefully close the stream - boost::system::error_code ec; + beast::error_code ec; stream.shutdown(ec); - if(ec == boost::asio::error::eof) + if(ec == net::error::eof) { // Rationale: // http://stackoverflow.com/questions/25587403/boost-asio-ssl-async-shutdown-always-finishes-with-an-error ec.assign(0, ec.category()); } if(ec) - throw boost::system::system_error{ec}; + throw beast::system_error{ec}; // If we get here then the connection is closed gracefully } diff --git a/example/http/client/sync/http_client_sync.cpp b/example/http/client/sync/http_client_sync.cpp index 9189f015..130aa719 100644 --- a/example/http/client/sync/http_client_sync.cpp +++ b/example/http/client/sync/http_client_sync.cpp @@ -24,8 +24,10 @@ #include #include -using tcp = boost::asio::ip::tcp; // from -namespace http = boost::beast::http; // from +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +using tcp = net::ip::tcp; // from // Performs an HTTP GET and prints the response int main(int argc, char** argv) @@ -48,7 +50,7 @@ int main(int argc, char** argv) int version = argc == 5 && !std::strcmp("1.0", argv[4]) ? 10 : 11; // The io_context is required for all I/O - boost::asio::io_context ioc; + net::io_context ioc; // These objects perform our I/O tcp::resolver resolver{ioc}; @@ -58,7 +60,7 @@ int main(int argc, char** argv) auto const results = resolver.resolve(host, port); // Make the connection on the IP address we get from a lookup - boost::asio::connect(socket, results.begin(), results.end()); + net::connect(socket, results.begin(), results.end()); // Set up an HTTP GET request message http::request req{http::verb::get, target, version}; @@ -69,7 +71,7 @@ int main(int argc, char** argv) http::write(socket, req); // This buffer is used for reading and must be persisted - boost::beast::flat_buffer buffer; + beast::flat_buffer buffer; // Declare a container to hold the response http::response res; @@ -81,14 +83,14 @@ int main(int argc, char** argv) std::cout << res << std::endl; // Gracefully close the socket - boost::system::error_code ec; + beast::error_code ec; socket.shutdown(tcp::socket::shutdown_both, ec); // not_connected happens sometimes // so don't bother reporting it. // - if(ec && ec != boost::system::errc::not_connected) - throw boost::system::system_error{ec}; + if(ec && ec != beast::errc::not_connected) + throw beast::system_error{ec}; // If we get here then the connection is closed gracefully } diff --git a/example/http/server/async-ssl/http_server_async_ssl.cpp b/example/http/server/async-ssl/http_server_async_ssl.cpp index 538e6089..549e560c 100644 --- a/example/http/server/async-ssl/http_server_async_ssl.cpp +++ b/example/http/server/async-ssl/http_server_async_ssl.cpp @@ -32,20 +32,22 @@ #include #include -using tcp = boost::asio::ip::tcp; // from +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from namespace ssl = boost::asio::ssl; // from -namespace http = boost::beast::http; // from +using tcp = boost::asio::ip::tcp; // from // Return a reasonable mime type based on the extension of a file. -boost::beast::string_view -mime_type(boost::beast::string_view path) +beast::string_view +mime_type(beast::string_view path) { - using boost::beast::iequals; + using beast::iequals; auto const ext = [&path] { auto const pos = path.rfind("."); - if(pos == boost::beast::string_view::npos) - return boost::beast::string_view{}; + if(pos == beast::string_view::npos) + return beast::string_view{}; return path.substr(pos); }(); if(iequals(ext, ".htm")) return "text/html"; @@ -76,8 +78,8 @@ mime_type(boost::beast::string_view path) // The returned path is normalized for the platform. std::string path_cat( - boost::beast::string_view base, - boost::beast::string_view path) + beast::string_view base, + beast::string_view path) { if(base.empty()) return path.to_string(); @@ -108,13 +110,13 @@ template< class Send> void handle_request( - boost::beast::string_view doc_root, + beast::string_view doc_root, http::request>&& req, Send&& send) { // Returns a bad request response auto const bad_request = - [&req](boost::beast::string_view why) + [&req](beast::string_view why) { http::response res{http::status::bad_request, req.version()}; res.set(http::field::server, BOOST_BEAST_VERSION_STRING); @@ -127,7 +129,7 @@ handle_request( // Returns a not found response auto const not_found = - [&req](boost::beast::string_view target) + [&req](beast::string_view target) { http::response res{http::status::not_found, req.version()}; res.set(http::field::server, BOOST_BEAST_VERSION_STRING); @@ -140,7 +142,7 @@ handle_request( // Returns a server error response auto const server_error = - [&req](boost::beast::string_view what) + [&req](beast::string_view what) { http::response res{http::status::internal_server_error, req.version()}; res.set(http::field::server, BOOST_BEAST_VERSION_STRING); @@ -159,7 +161,7 @@ handle_request( // Request path must be absolute and not contain "..". if( req.target().empty() || req.target()[0] != '/' || - req.target().find("..") != boost::beast::string_view::npos) + req.target().find("..") != beast::string_view::npos) return send(bad_request("Illegal request-target")); // Build the path to the requested file @@ -168,12 +170,12 @@ handle_request( path.append("index.html"); // Attempt to open the file - boost::beast::error_code ec; + beast::error_code ec; http::file_body::value_type body; - body.open(path.c_str(), boost::beast::file_mode::scan, ec); + body.open(path.c_str(), beast::file_mode::scan, ec); // Handle the case where the file doesn't exist - if(ec == boost::system::errc::no_such_file_or_directory) + if(ec == beast::errc::no_such_file_or_directory) return send(not_found(req.target())); // Handle an unknown error @@ -210,7 +212,7 @@ handle_request( // Report a failure void -fail(boost::system::error_code ec, char const* what) +fail(beast::error_code ec, char const* what) { std::cerr << what << ": " << ec.message() << "\n"; } @@ -248,7 +250,7 @@ class session : public std::enable_shared_from_this http::async_write( self_.stream_, *sp, - boost::asio::bind_executor( + net::bind_executor( self_.strand_, std::bind( &session::on_write, @@ -261,9 +263,9 @@ class session : public std::enable_shared_from_this tcp::socket socket_; ssl::stream stream_; - boost::asio::strand< - boost::asio::io_context::executor_type> strand_; - boost::beast::flat_buffer buffer_; + net::strand< + net::io_context::executor_type> strand_; + beast::flat_buffer buffer_; std::shared_ptr doc_root_; http::request req_; std::shared_ptr res_; @@ -291,7 +293,7 @@ public: // Perform the SSL handshake stream_.async_handshake( ssl::stream_base::server, - boost::asio::bind_executor( + net::bind_executor( strand_, std::bind( &session::on_handshake, @@ -300,7 +302,7 @@ public: } void - on_handshake(boost::system::error_code ec) + on_handshake(beast::error_code ec) { if(ec) return fail(ec, "handshake"); @@ -317,7 +319,7 @@ public: // Read a request http::async_read(stream_, buffer_, req_, - boost::asio::bind_executor( + net::bind_executor( strand_, std::bind( &session::on_read, @@ -328,7 +330,7 @@ public: void on_read( - boost::system::error_code ec, + beast::error_code ec, std::size_t bytes_transferred) { boost::ignore_unused(bytes_transferred); @@ -346,7 +348,7 @@ public: void on_write( - boost::system::error_code ec, + beast::error_code ec, std::size_t bytes_transferred, bool close) { @@ -374,7 +376,7 @@ public: { // Perform the SSL shutdown stream_.async_shutdown( - boost::asio::bind_executor( + net::bind_executor( strand_, std::bind( &session::on_shutdown, @@ -383,7 +385,7 @@ public: } void - on_shutdown(boost::system::error_code ec) + on_shutdown(beast::error_code ec) { if(ec) return fail(ec, "shutdown"); @@ -404,7 +406,7 @@ class listener : public std::enable_shared_from_this public: listener( - boost::asio::io_context& ioc, + net::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint, std::shared_ptr const& doc_root) @@ -413,7 +415,7 @@ public: , socket_(ioc) , doc_root_(doc_root) { - boost::system::error_code ec; + beast::error_code ec; // Open the acceptor acceptor_.open(endpoint.protocol(), ec); @@ -424,7 +426,7 @@ public: } // Allow address reuse - acceptor_.set_option(boost::asio::socket_base::reuse_address(true), ec); + acceptor_.set_option(net::socket_base::reuse_address(true), ec); if(ec) { fail(ec, "set_option"); @@ -441,7 +443,7 @@ public: // Start listening for connections acceptor_.listen( - boost::asio::socket_base::max_listen_connections, ec); + net::socket_base::max_listen_connections, ec); if(ec) { fail(ec, "listen"); @@ -470,7 +472,7 @@ public: } void - on_accept(boost::system::error_code ec) + on_accept(beast::error_code ec) { if(ec) { @@ -503,13 +505,13 @@ int main(int argc, char* argv[]) " http-server-async-ssl 0.0.0.0 8080 . 1\n"; return EXIT_FAILURE; } - auto const address = boost::asio::ip::make_address(argv[1]); + auto const address = net::ip::make_address(argv[1]); auto const port = static_cast(std::atoi(argv[2])); auto const doc_root = std::make_shared(argv[3]); auto const threads = std::max(1, std::atoi(argv[4])); // The io_context is required for all I/O - boost::asio::io_context ioc{threads}; + net::io_context ioc{threads}; // The SSL context is required, and holds certificates ssl::context ctx{ssl::context::sslv23}; diff --git a/example/http/server/async/http_server_async.cpp b/example/http/server/async/http_server_async.cpp index 96a01d14..d7ada283 100644 --- a/example/http/server/async/http_server_async.cpp +++ b/example/http/server/async/http_server_async.cpp @@ -29,19 +29,21 @@ #include #include +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from using tcp = boost::asio::ip::tcp; // from -namespace http = boost::beast::http; // from // Return a reasonable mime type based on the extension of a file. -boost::beast::string_view -mime_type(boost::beast::string_view path) +beast::string_view +mime_type(beast::string_view path) { - using boost::beast::iequals; + using beast::iequals; auto const ext = [&path] { auto const pos = path.rfind("."); - if(pos == boost::beast::string_view::npos) - return boost::beast::string_view{}; + if(pos == beast::string_view::npos) + return beast::string_view{}; return path.substr(pos); }(); if(iequals(ext, ".htm")) return "text/html"; @@ -72,8 +74,8 @@ mime_type(boost::beast::string_view path) // The returned path is normalized for the platform. std::string path_cat( - boost::beast::string_view base, - boost::beast::string_view path) + beast::string_view base, + beast::string_view path) { if(base.empty()) return path.to_string(); @@ -104,13 +106,13 @@ template< class Send> void handle_request( - boost::beast::string_view doc_root, + beast::string_view doc_root, http::request>&& req, Send&& send) { // Returns a bad request response auto const bad_request = - [&req](boost::beast::string_view why) + [&req](beast::string_view why) { http::response res{http::status::bad_request, req.version()}; res.set(http::field::server, BOOST_BEAST_VERSION_STRING); @@ -123,7 +125,7 @@ handle_request( // Returns a not found response auto const not_found = - [&req](boost::beast::string_view target) + [&req](beast::string_view target) { http::response res{http::status::not_found, req.version()}; res.set(http::field::server, BOOST_BEAST_VERSION_STRING); @@ -136,7 +138,7 @@ handle_request( // Returns a server error response auto const server_error = - [&req](boost::beast::string_view what) + [&req](beast::string_view what) { http::response res{http::status::internal_server_error, req.version()}; res.set(http::field::server, BOOST_BEAST_VERSION_STRING); @@ -155,7 +157,7 @@ handle_request( // Request path must be absolute and not contain "..". if( req.target().empty() || req.target()[0] != '/' || - req.target().find("..") != boost::beast::string_view::npos) + req.target().find("..") != beast::string_view::npos) return send(bad_request("Illegal request-target")); // Build the path to the requested file @@ -164,12 +166,12 @@ handle_request( path.append("index.html"); // Attempt to open the file - boost::beast::error_code ec; + beast::error_code ec; http::file_body::value_type body; - body.open(path.c_str(), boost::beast::file_mode::scan, ec); + body.open(path.c_str(), beast::file_mode::scan, ec); // Handle the case where the file doesn't exist - if(ec == boost::system::errc::no_such_file_or_directory) + if(ec == beast::errc::no_such_file_or_directory) return send(not_found(req.target())); // Handle an unknown error @@ -206,7 +208,7 @@ handle_request( // Report a failure void -fail(boost::system::error_code ec, char const* what) +fail(beast::error_code ec, char const* what) { std::cerr << what << ": " << ec.message() << "\n"; } @@ -244,7 +246,7 @@ class session : public std::enable_shared_from_this http::async_write( self_.socket_, *sp, - boost::asio::bind_executor( + net::bind_executor( self_.strand_, std::bind( &session::on_write, @@ -256,9 +258,9 @@ class session : public std::enable_shared_from_this }; tcp::socket socket_; - boost::asio::strand< - boost::asio::io_context::executor_type> strand_; - boost::beast::flat_buffer buffer_; + net::strand< + net::io_context::executor_type> strand_; + beast::flat_buffer buffer_; std::shared_ptr doc_root_; http::request req_; std::shared_ptr res_; @@ -293,7 +295,7 @@ public: // Read a request http::async_read(socket_, buffer_, req_, - boost::asio::bind_executor( + net::bind_executor( strand_, std::bind( &session::on_read, @@ -304,7 +306,7 @@ public: void on_read( - boost::system::error_code ec, + beast::error_code ec, std::size_t bytes_transferred) { boost::ignore_unused(bytes_transferred); @@ -322,7 +324,7 @@ public: void on_write( - boost::system::error_code ec, + beast::error_code ec, std::size_t bytes_transferred, bool close) { @@ -349,7 +351,7 @@ public: do_close() { // Send a TCP shutdown - boost::system::error_code ec; + beast::error_code ec; socket_.shutdown(tcp::socket::shutdown_send, ec); // At this point the connection is closed gracefully @@ -367,14 +369,14 @@ class listener : public std::enable_shared_from_this public: listener( - boost::asio::io_context& ioc, + net::io_context& ioc, tcp::endpoint endpoint, std::shared_ptr const& doc_root) : acceptor_(ioc) , socket_(ioc) , doc_root_(doc_root) { - boost::system::error_code ec; + beast::error_code ec; // Open the acceptor acceptor_.open(endpoint.protocol(), ec); @@ -385,7 +387,7 @@ public: } // Allow address reuse - acceptor_.set_option(boost::asio::socket_base::reuse_address(true), ec); + acceptor_.set_option(net::socket_base::reuse_address(true), ec); if(ec) { fail(ec, "set_option"); @@ -402,7 +404,7 @@ public: // Start listening for connections acceptor_.listen( - boost::asio::socket_base::max_listen_connections, ec); + net::socket_base::max_listen_connections, ec); if(ec) { fail(ec, "listen"); @@ -431,7 +433,7 @@ public: } void - on_accept(boost::system::error_code ec) + on_accept(beast::error_code ec) { if(ec) { @@ -463,13 +465,13 @@ int main(int argc, char* argv[]) " http-server-async 0.0.0.0 8080 . 1\n"; return EXIT_FAILURE; } - auto const address = boost::asio::ip::make_address(argv[1]); + auto const address = net::ip::make_address(argv[1]); auto const port = static_cast(std::atoi(argv[2])); auto const doc_root = std::make_shared(argv[3]); auto const threads = std::max(1, std::atoi(argv[4])); // The io_context is required for all I/O - boost::asio::io_context ioc{threads}; + net::io_context ioc{threads}; // Create and launch a listening port std::make_shared( diff --git a/example/http/server/coro-ssl/http_server_coro_ssl.cpp b/example/http/server/coro-ssl/http_server_coro_ssl.cpp index 5f50feba..63cdc4c8 100644 --- a/example/http/server/coro-ssl/http_server_coro_ssl.cpp +++ b/example/http/server/coro-ssl/http_server_coro_ssl.cpp @@ -30,20 +30,22 @@ #include #include -using tcp = boost::asio::ip::tcp; // from +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from namespace ssl = boost::asio::ssl; // from -namespace http = boost::beast::http; // from +using tcp = boost::asio::ip::tcp; // from // Return a reasonable mime type based on the extension of a file. -boost::beast::string_view -mime_type(boost::beast::string_view path) +beast::string_view +mime_type(beast::string_view path) { - using boost::beast::iequals; + using beast::iequals; auto const ext = [&path] { auto const pos = path.rfind("."); - if(pos == boost::beast::string_view::npos) - return boost::beast::string_view{}; + if(pos == beast::string_view::npos) + return beast::string_view{}; return path.substr(pos); }(); if(iequals(ext, ".htm")) return "text/html"; @@ -74,8 +76,8 @@ mime_type(boost::beast::string_view path) // The returned path is normalized for the platform. std::string path_cat( - boost::beast::string_view base, - boost::beast::string_view path) + beast::string_view base, + beast::string_view path) { if(base.empty()) return path.to_string(); @@ -106,13 +108,13 @@ template< class Send> void handle_request( - boost::beast::string_view doc_root, + beast::string_view doc_root, http::request>&& req, Send&& send) { // Returns a bad request response auto const bad_request = - [&req](boost::beast::string_view why) + [&req](beast::string_view why) { http::response res{http::status::bad_request, req.version()}; res.set(http::field::server, BOOST_BEAST_VERSION_STRING); @@ -125,7 +127,7 @@ handle_request( // Returns a not found response auto const not_found = - [&req](boost::beast::string_view target) + [&req](beast::string_view target) { http::response res{http::status::not_found, req.version()}; res.set(http::field::server, BOOST_BEAST_VERSION_STRING); @@ -138,7 +140,7 @@ handle_request( // Returns a server error response auto const server_error = - [&req](boost::beast::string_view what) + [&req](beast::string_view what) { http::response res{http::status::internal_server_error, req.version()}; res.set(http::field::server, BOOST_BEAST_VERSION_STRING); @@ -157,7 +159,7 @@ handle_request( // Request path must be absolute and not contain "..". if( req.target().empty() || req.target()[0] != '/' || - req.target().find("..") != boost::beast::string_view::npos) + req.target().find("..") != beast::string_view::npos) return send(bad_request("Illegal request-target")); // Build the path to the requested file @@ -166,12 +168,12 @@ handle_request( path.append("index.html"); // Attempt to open the file - boost::beast::error_code ec; + beast::error_code ec; http::file_body::value_type body; - body.open(path.c_str(), boost::beast::file_mode::scan, ec); + body.open(path.c_str(), beast::file_mode::scan, ec); // Handle the case where the file doesn't exist - if(ec == boost::system::errc::no_such_file_or_directory) + if(ec == beast::errc::no_such_file_or_directory) return send(not_found(req.target())); // Handle an unknown error @@ -208,7 +210,7 @@ handle_request( // Report a failure void -fail(boost::system::error_code ec, char const* what) +fail(beast::error_code ec, char const* what) { std::cerr << what << ": " << ec.message() << "\n"; } @@ -220,15 +222,15 @@ struct send_lambda { Stream& stream_; bool& close_; - boost::system::error_code& ec_; - boost::asio::yield_context yield_; + beast::error_code& ec_; + net::yield_context yield_; explicit send_lambda( Stream& stream, bool& close, - boost::system::error_code& ec, - boost::asio::yield_context yield) + beast::error_code& ec, + net::yield_context yield) : stream_(stream) , close_(close) , ec_(ec) @@ -257,10 +259,10 @@ do_session( tcp::socket& socket, ssl::context& ctx, std::shared_ptr const& doc_root, - boost::asio::yield_context yield) + net::yield_context yield) { bool close = false; - boost::system::error_code ec; + beast::error_code ec; // Construct the stream around the socket ssl::stream stream{socket, ctx}; @@ -271,7 +273,7 @@ do_session( return fail(ec, "handshake"); // This buffer is required to persist across reads - boost::beast::flat_buffer buffer; + beast::flat_buffer buffer; // This lambda is used to send messages send_lambda> lambda{stream, close, ec, yield}; @@ -311,13 +313,13 @@ do_session( // Accepts incoming connections and launches the sessions void do_listen( - boost::asio::io_context& ioc, + net::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint, std::shared_ptr const& doc_root, - boost::asio::yield_context yield) + net::yield_context yield) { - boost::system::error_code ec; + beast::error_code ec; // Open the acceptor tcp::acceptor acceptor(ioc); @@ -326,7 +328,7 @@ do_listen( return fail(ec, "open"); // Allow address reuse - acceptor.set_option(boost::asio::socket_base::reuse_address(true), ec); + acceptor.set_option(net::socket_base::reuse_address(true), ec); if(ec) return fail(ec, "set_option"); @@ -336,7 +338,7 @@ do_listen( return fail(ec, "bind"); // Start listening for connections - acceptor.listen(boost::asio::socket_base::max_listen_connections, ec); + acceptor.listen(net::socket_base::max_listen_connections, ec); if(ec) return fail(ec, "listen"); @@ -347,7 +349,7 @@ do_listen( if(ec) fail(ec, "accept"); else - boost::asio::spawn( + net::spawn( acceptor.get_executor().context(), std::bind( &do_session, @@ -369,13 +371,13 @@ int main(int argc, char* argv[]) " http-server-coro-ssl 0.0.0.0 8080 . 1\n"; return EXIT_FAILURE; } - auto const address = boost::asio::ip::make_address(argv[1]); + auto const address = net::ip::make_address(argv[1]); auto const port = static_cast(std::atoi(argv[2])); auto const doc_root = std::make_shared(argv[3]); auto const threads = std::max(1, std::atoi(argv[4])); // The io_context is required for all I/O - boost::asio::io_context ioc{threads}; + net::io_context ioc{threads}; // The SSL context is required, and holds certificates ssl::context ctx{ssl::context::sslv23}; @@ -384,7 +386,7 @@ int main(int argc, char* argv[]) load_server_certificate(ctx); // Spawn a listening port - boost::asio::spawn(ioc, + net::spawn(ioc, std::bind( &do_listen, std::ref(ioc), diff --git a/example/http/server/coro/http_server_coro.cpp b/example/http/server/coro/http_server_coro.cpp index c985b38a..4fc3a453 100644 --- a/example/http/server/coro/http_server_coro.cpp +++ b/example/http/server/coro/http_server_coro.cpp @@ -27,19 +27,21 @@ #include #include +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from using tcp = boost::asio::ip::tcp; // from -namespace http = boost::beast::http; // from // Return a reasonable mime type based on the extension of a file. -boost::beast::string_view -mime_type(boost::beast::string_view path) +beast::string_view +mime_type(beast::string_view path) { - using boost::beast::iequals; + using beast::iequals; auto const ext = [&path] { auto const pos = path.rfind("."); - if(pos == boost::beast::string_view::npos) - return boost::beast::string_view{}; + if(pos == beast::string_view::npos) + return beast::string_view{}; return path.substr(pos); }(); if(iequals(ext, ".htm")) return "text/html"; @@ -70,8 +72,8 @@ mime_type(boost::beast::string_view path) // The returned path is normalized for the platform. std::string path_cat( - boost::beast::string_view base, - boost::beast::string_view path) + beast::string_view base, + beast::string_view path) { if(base.empty()) return path.to_string(); @@ -102,13 +104,13 @@ template< class Send> void handle_request( - boost::beast::string_view doc_root, + beast::string_view doc_root, http::request>&& req, Send&& send) { // Returns a bad request response auto const bad_request = - [&req](boost::beast::string_view why) + [&req](beast::string_view why) { http::response res{http::status::bad_request, req.version()}; res.set(http::field::server, BOOST_BEAST_VERSION_STRING); @@ -121,7 +123,7 @@ handle_request( // Returns a not found response auto const not_found = - [&req](boost::beast::string_view target) + [&req](beast::string_view target) { http::response res{http::status::not_found, req.version()}; res.set(http::field::server, BOOST_BEAST_VERSION_STRING); @@ -134,7 +136,7 @@ handle_request( // Returns a server error response auto const server_error = - [&req](boost::beast::string_view what) + [&req](beast::string_view what) { http::response res{http::status::internal_server_error, req.version()}; res.set(http::field::server, BOOST_BEAST_VERSION_STRING); @@ -153,7 +155,7 @@ handle_request( // Request path must be absolute and not contain "..". if( req.target().empty() || req.target()[0] != '/' || - req.target().find("..") != boost::beast::string_view::npos) + req.target().find("..") != beast::string_view::npos) return send(bad_request("Illegal request-target")); // Build the path to the requested file @@ -162,12 +164,12 @@ handle_request( path.append("index.html"); // Attempt to open the file - boost::beast::error_code ec; + beast::error_code ec; http::file_body::value_type body; - body.open(path.c_str(), boost::beast::file_mode::scan, ec); + body.open(path.c_str(), beast::file_mode::scan, ec); // Handle the case where the file doesn't exist - if(ec == boost::system::errc::no_such_file_or_directory) + if(ec == beast::errc::no_such_file_or_directory) return send(not_found(req.target())); // Handle an unknown error @@ -204,7 +206,7 @@ handle_request( // Report a failure void -fail(boost::system::error_code ec, char const* what) +fail(beast::error_code ec, char const* what) { std::cerr << what << ": " << ec.message() << "\n"; } @@ -216,15 +218,15 @@ struct send_lambda { Stream& stream_; bool& close_; - boost::system::error_code& ec_; - boost::asio::yield_context yield_; + beast::error_code& ec_; + net::yield_context yield_; explicit send_lambda( Stream& stream, bool& close, - boost::system::error_code& ec, - boost::asio::yield_context yield) + beast::error_code& ec, + net::yield_context yield) : stream_(stream) , close_(close) , ec_(ec) @@ -252,13 +254,13 @@ void do_session( tcp::socket& socket, std::shared_ptr const& doc_root, - boost::asio::yield_context yield) + net::yield_context yield) { bool close = false; - boost::system::error_code ec; + beast::error_code ec; // This buffer is required to persist across reads - boost::beast::flat_buffer buffer; + beast::flat_buffer buffer; // This lambda is used to send messages send_lambda lambda{socket, close, ec, yield}; @@ -296,12 +298,12 @@ do_session( // Accepts incoming connections and launches the sessions void do_listen( - boost::asio::io_context& ioc, + net::io_context& ioc, tcp::endpoint endpoint, std::shared_ptr const& doc_root, - boost::asio::yield_context yield) + net::yield_context yield) { - boost::system::error_code ec; + beast::error_code ec; // Open the acceptor tcp::acceptor acceptor(ioc); @@ -310,7 +312,7 @@ do_listen( return fail(ec, "open"); // Allow address reuse - acceptor.set_option(boost::asio::socket_base::reuse_address(true), ec); + acceptor.set_option(net::socket_base::reuse_address(true), ec); if(ec) return fail(ec, "set_option"); @@ -320,7 +322,7 @@ do_listen( return fail(ec, "bind"); // Start listening for connections - acceptor.listen(boost::asio::socket_base::max_listen_connections, ec); + acceptor.listen(net::socket_base::max_listen_connections, ec); if(ec) return fail(ec, "listen"); @@ -331,7 +333,7 @@ do_listen( if(ec) fail(ec, "accept"); else - boost::asio::spawn( + net::spawn( acceptor.get_executor().context(), std::bind( &do_session, @@ -352,16 +354,16 @@ int main(int argc, char* argv[]) " http-server-coro 0.0.0.0 8080 . 1\n"; return EXIT_FAILURE; } - auto const address = boost::asio::ip::make_address(argv[1]); + auto const address = net::ip::make_address(argv[1]); auto const port = static_cast(std::atoi(argv[2])); auto const doc_root = std::make_shared(argv[3]); auto const threads = std::max(1, std::atoi(argv[4])); // The io_context is required for all I/O - boost::asio::io_context ioc{threads}; + net::io_context ioc{threads}; // Spawn a listening port - boost::asio::spawn(ioc, + net::spawn(ioc, std::bind( &do_listen, std::ref(ioc), diff --git a/example/http/server/fast/http_server_fast.cpp b/example/http/server/fast/http_server_fast.cpp index 37c19edb..eb3e4ca2 100644 --- a/example/http/server/fast/http_server_fast.cpp +++ b/example/http/server/fast/http_server_fast.cpp @@ -28,20 +28,21 @@ #include #include -namespace ip = boost::asio::ip; // from -using tcp = boost::asio::ip::tcp; // from -namespace http = boost::beast::http; // from +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +using tcp = boost::asio::ip::tcp; // from // Return a reasonable mime type based on the extension of a file. -boost::beast::string_view -mime_type(boost::beast::string_view path) +beast::string_view +mime_type(beast::string_view path) { - using boost::beast::iequals; + using beast::iequals; auto const ext = [&path] { auto const pos = path.rfind("."); - if(pos == boost::beast::string_view::npos) - return boost::beast::string_view{}; + if(pos == beast::string_view::npos) + return beast::string_view{}; return path.substr(pos); }(); if(iequals(ext, ".htm")) return "text/html"; @@ -88,7 +89,7 @@ public: private: using alloc_t = fields_alloc; - //using request_body_t = http::basic_dynamic_body>; + //using request_body_t = http::basic_dynamic_body>; using request_body_t = http::string_body; // The acceptor used to listen for incoming connections. @@ -101,7 +102,7 @@ private: tcp::socket socket_{acceptor_.get_executor().context()}; // The buffer for performing reads - boost::beast::flat_static_buffer<8192> buffer_; + beast::flat_static_buffer<8192> buffer_; // The allocator used for the fields in the request and reply. alloc_t alloc_{8192}; @@ -110,7 +111,7 @@ private: boost::optional> parser_; // The timer putting a time limit on requests. - boost::asio::basic_waitable_timer request_deadline_{ + net::basic_waitable_timer request_deadline_{ acceptor_.get_executor().context(), (std::chrono::steady_clock::time_point::max)()}; // The string-based response message. @@ -128,13 +129,13 @@ private: void accept() { // Clean up any previous connection. - boost::beast::error_code ec; + beast::error_code ec; socket_.close(ec); buffer_.consume(buffer_.size()); acceptor_.async_accept( socket_, - [this](boost::beast::error_code ec) + [this](beast::error_code ec) { if (ec) { @@ -173,7 +174,7 @@ private: socket_, buffer_, *parser_, - [this](boost::beast::error_code ec, std::size_t) + [this](beast::error_code ec, std::size_t) { if (ec) accept(); @@ -221,7 +222,7 @@ private: http::async_write( socket_, *string_serializer_, - [this](boost::beast::error_code ec, std::size_t) + [this](beast::error_code ec, std::size_t) { socket_.shutdown(tcp::socket::shutdown_send, ec); string_serializer_.reset(); @@ -230,7 +231,7 @@ private: }); } - void send_file(boost::beast::string_view target) + void send_file(beast::string_view target) { // Request path must be absolute and not contain "..". if (target.empty() || target[0] != '/' || target.find("..") != std::string::npos) @@ -247,10 +248,10 @@ private: target.size()); http::file_body::value_type file; - boost::beast::error_code ec; + beast::error_code ec; file.open( full_path.c_str(), - boost::beast::file_mode::read, + beast::file_mode::read, ec); if(ec) { @@ -277,7 +278,7 @@ private: http::async_write( socket_, *file_serializer_, - [this](boost::beast::error_code ec, std::size_t) + [this](beast::error_code ec, std::size_t) { socket_.shutdown(tcp::socket::shutdown_send, ec); file_serializer_.reset(); @@ -292,7 +293,7 @@ private: if (request_deadline_.expiry() <= std::chrono::steady_clock::now()) { // Close socket to cancel any outstanding operation. - boost::beast::error_code ec; + beast::error_code ec; socket_.close(); // Sleep indefinitely until we're given a new deadline. @@ -301,7 +302,7 @@ private: } request_deadline_.async_wait( - [this](boost::beast::error_code) + [this](beast::error_code) { check_deadline(); }); @@ -323,13 +324,13 @@ int main(int argc, char* argv[]) return EXIT_FAILURE; } - auto const address = boost::asio::ip::make_address(argv[1]); + auto const address = net::ip::make_address(argv[1]); unsigned short port = static_cast(std::atoi(argv[2])); std::string doc_root = argv[3]; int num_workers = std::atoi(argv[4]); bool spin = (std::strcmp(argv[5], "spin") == 0); - boost::asio::io_context ioc{1}; + net::io_context ioc{1}; tcp::acceptor acceptor{ioc, {address, port}}; std::list workers; diff --git a/example/http/server/flex/http_server_flex.cpp b/example/http/server/flex/http_server_flex.cpp index 96c97de5..08700c3b 100644 --- a/example/http/server/flex/http_server_flex.cpp +++ b/example/http/server/flex/http_server_flex.cpp @@ -32,20 +32,22 @@ #include #include -using tcp = boost::asio::ip::tcp; // from +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from namespace ssl = boost::asio::ssl; // from -namespace http = boost::beast::http; // from +using tcp = boost::asio::ip::tcp; // from // Return a reasonable mime type based on the extension of a file. -boost::beast::string_view -mime_type(boost::beast::string_view path) +beast::string_view +mime_type(beast::string_view path) { - using boost::beast::iequals; + using beast::iequals; auto const ext = [&path] { auto const pos = path.rfind("."); - if(pos == boost::beast::string_view::npos) - return boost::beast::string_view{}; + if(pos == beast::string_view::npos) + return beast::string_view{}; return path.substr(pos); }(); if(iequals(ext, ".htm")) return "text/html"; @@ -76,8 +78,8 @@ mime_type(boost::beast::string_view path) // The returned path is normalized for the platform. std::string path_cat( - boost::beast::string_view base, - boost::beast::string_view path) + beast::string_view base, + beast::string_view path) { if(base.empty()) return path.to_string(); @@ -108,13 +110,13 @@ template< class Send> void handle_request( - boost::beast::string_view doc_root, + beast::string_view doc_root, http::request>&& req, Send&& send) { // Returns a bad request response auto const bad_request = - [&req](boost::beast::string_view why) + [&req](beast::string_view why) { http::response res{http::status::bad_request, req.version()}; res.set(http::field::server, BOOST_BEAST_VERSION_STRING); @@ -127,7 +129,7 @@ handle_request( // Returns a not found response auto const not_found = - [&req](boost::beast::string_view target) + [&req](beast::string_view target) { http::response res{http::status::not_found, req.version()}; res.set(http::field::server, BOOST_BEAST_VERSION_STRING); @@ -140,7 +142,7 @@ handle_request( // Returns a server error response auto const server_error = - [&req](boost::beast::string_view what) + [&req](beast::string_view what) { http::response res{http::status::internal_server_error, req.version()}; res.set(http::field::server, BOOST_BEAST_VERSION_STRING); @@ -159,7 +161,7 @@ handle_request( // Request path must be absolute and not contain "..". if( req.target().empty() || req.target()[0] != '/' || - req.target().find("..") != boost::beast::string_view::npos) + req.target().find("..") != beast::string_view::npos) return send(bad_request("Illegal request-target")); // Build the path to the requested file @@ -168,12 +170,12 @@ handle_request( path.append("index.html"); // Attempt to open the file - boost::beast::error_code ec; + beast::error_code ec; http::file_body::value_type body; - body.open(path.c_str(), boost::beast::file_mode::scan, ec); + body.open(path.c_str(), beast::file_mode::scan, ec); // Handle the case where the file doesn't exist - if(ec == boost::system::errc::no_such_file_or_directory) + if(ec == beast::errc::no_such_file_or_directory) return send(not_found(req.target())); // Handle an unknown error @@ -210,7 +212,7 @@ handle_request( // Report a failure void -fail(boost::system::error_code ec, char const* what) +fail(beast::error_code ec, char const* what) { std::cerr << what << ": " << ec.message() << "\n"; } @@ -259,7 +261,7 @@ class session http::async_write( self_.derived().stream(), *sp, - boost::asio::bind_executor( + net::bind_executor( self_.strand_, std::bind( &session::on_write, @@ -276,16 +278,16 @@ class session send_lambda lambda_; protected: - boost::asio::strand< - boost::asio::io_context::executor_type> strand_; - boost::beast::flat_buffer buffer_; + net::strand< + net::io_context::executor_type> strand_; + beast::flat_buffer buffer_; public: // Take ownership of the buffer explicit session( - boost::asio::io_context& ioc, - boost::beast::flat_buffer buffer, + net::io_context& ioc, + beast::flat_buffer buffer, std::shared_ptr const& doc_root) : doc_root_(doc_root) , lambda_(*this) @@ -302,7 +304,7 @@ public: derived().stream(), buffer_, req_, - boost::asio::bind_executor( + net::bind_executor( strand_, std::bind( &session::on_read, @@ -313,7 +315,7 @@ public: void on_read( - boost::system::error_code ec, + beast::error_code ec, std::size_t bytes_transferred) { boost::ignore_unused(bytes_transferred); @@ -331,7 +333,7 @@ public: void on_write( - boost::system::error_code ec, + beast::error_code ec, std::size_t bytes_transferred, bool close) { @@ -361,14 +363,14 @@ class plain_session , public std::enable_shared_from_this { tcp::socket socket_; - boost::asio::strand< - boost::asio::io_context::executor_type> strand_; + net::strand< + net::io_context::executor_type> strand_; public: // Create the session plain_session( tcp::socket socket, - boost::beast::flat_buffer buffer, + beast::flat_buffer buffer, std::shared_ptr const& doc_root) : session( socket.get_executor().context(), @@ -397,7 +399,7 @@ public: do_eof() { // Send a TCP shutdown - boost::system::error_code ec; + beast::error_code ec; socket_.shutdown(tcp::socket::shutdown_send, ec); // At this point the connection is closed gracefully @@ -411,15 +413,15 @@ class ssl_session { tcp::socket socket_; ssl::stream stream_; - boost::asio::strand< - boost::asio::io_context::executor_type> strand_; + net::strand< + net::io_context::executor_type> strand_; public: // Create the session ssl_session( tcp::socket socket, ssl::context& ctx, - boost::beast::flat_buffer buffer, + beast::flat_buffer buffer, std::shared_ptr const& doc_root) : session( socket.get_executor().context(), @@ -447,7 +449,7 @@ public: stream_.async_handshake( ssl::stream_base::server, buffer_.data(), - boost::asio::bind_executor( + net::bind_executor( strand_, std::bind( &ssl_session::on_handshake, @@ -457,7 +459,7 @@ public: } void on_handshake( - boost::system::error_code ec, + beast::error_code ec, std::size_t bytes_used) { if(ec) @@ -474,7 +476,7 @@ public: { // Perform the SSL shutdown stream_.async_shutdown( - boost::asio::bind_executor( + net::bind_executor( strand_, std::bind( &ssl_session::on_shutdown, @@ -483,7 +485,7 @@ public: } void - on_shutdown(boost::system::error_code ec) + on_shutdown(beast::error_code ec) { if(ec) return fail(ec, "shutdown"); @@ -499,10 +501,10 @@ class detect_session : public std::enable_shared_from_this { tcp::socket socket_; ssl::context& ctx_; - boost::asio::strand< - boost::asio::io_context::executor_type> strand_; + net::strand< + net::io_context::executor_type> strand_; std::shared_ptr doc_root_; - boost::beast::flat_buffer buffer_; + beast::flat_buffer buffer_; public: explicit @@ -524,7 +526,7 @@ public: async_detect_ssl( socket_, buffer_, - boost::asio::bind_executor( + net::bind_executor( strand_, std::bind( &detect_session::on_detect, @@ -535,7 +537,7 @@ public: } void - on_detect(boost::system::error_code ec, boost::tribool result) + on_detect(beast::error_code ec, boost::tribool result) { if(ec) return fail(ec, "detect"); @@ -563,15 +565,15 @@ public: class listener : public std::enable_shared_from_this { ssl::context& ctx_; - boost::asio::strand< - boost::asio::io_context::executor_type> strand_; + net::strand< + net::io_context::executor_type> strand_; tcp::acceptor acceptor_; tcp::socket socket_; std::shared_ptr doc_root_; public: listener( - boost::asio::io_context& ioc, + net::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint, std::shared_ptr const& doc_root) @@ -581,7 +583,7 @@ public: , socket_(ioc) , doc_root_(doc_root) { - boost::system::error_code ec; + beast::error_code ec; // Open the acceptor acceptor_.open(endpoint.protocol(), ec); @@ -592,7 +594,7 @@ public: } // Allow address reuse - acceptor_.set_option(boost::asio::socket_base::reuse_address(true), ec); + acceptor_.set_option(net::socket_base::reuse_address(true), ec); if(ec) { fail(ec, "set_option"); @@ -609,7 +611,7 @@ public: // Start listening for connections acceptor_.listen( - boost::asio::socket_base::max_listen_connections, ec); + net::socket_base::max_listen_connections, ec); if(ec) { fail(ec, "listen"); @@ -638,7 +640,7 @@ public: } void - on_accept(boost::system::error_code ec) + on_accept(beast::error_code ec) { if(ec) { @@ -671,13 +673,13 @@ int main(int argc, char* argv[]) " http-server-flex 0.0.0.0 8080 .\n"; return EXIT_FAILURE; } - auto const address = boost::asio::ip::make_address(argv[1]); + auto const address = net::ip::make_address(argv[1]); auto const port = static_cast(std::atoi(argv[2])); auto const doc_root = std::make_shared(argv[3]); auto const threads = std::max(1, std::atoi(argv[4])); // The io_context is required for all I/O - boost::asio::io_context ioc{threads}; + net::io_context ioc{threads}; // The SSL context is required, and holds certificates ssl::context ctx{ssl::context::sslv23}; diff --git a/example/http/server/small/http_server_small.cpp b/example/http/server/small/http_server_small.cpp index 248eb449..111e5414 100644 --- a/example/http/server/small/http_server_small.cpp +++ b/example/http/server/small/http_server_small.cpp @@ -24,9 +24,10 @@ #include #include -namespace ip = boost::asio::ip; // from -using tcp = boost::asio::ip::tcp; // from -namespace http = boost::beast::http; // from +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from +using tcp = boost::asio::ip::tcp; // from namespace my_program_state { @@ -65,7 +66,7 @@ private: tcp::socket socket_; // The buffer for performing reads. - boost::beast::flat_buffer buffer_{8192}; + beast::flat_buffer buffer_{8192}; // The request message. http::request request_; @@ -74,7 +75,7 @@ private: http::response response_; // The timer for putting a deadline on connection processing. - boost::asio::basic_waitable_timer deadline_{ + net::basic_waitable_timer deadline_{ socket_.get_executor().context(), std::chrono::seconds(60)}; // Asynchronously receive a complete request message. @@ -87,7 +88,7 @@ private: socket_, buffer_, request_, - [self](boost::beast::error_code ec, + [self](beast::error_code ec, std::size_t bytes_transferred) { boost::ignore_unused(bytes_transferred); @@ -116,7 +117,7 @@ private: // we do not recognize the request method. response_.result(http::status::bad_request); response_.set(http::field::content_type, "text/plain"); - boost::beast::ostream(response_.body()) + beast::ostream(response_.body()) << "Invalid request-method '" << request_.method_string().to_string() << "'"; @@ -133,7 +134,7 @@ private: if(request_.target() == "/count") { response_.set(http::field::content_type, "text/html"); - boost::beast::ostream(response_.body()) + beast::ostream(response_.body()) << "\n" << "Request count\n" << "\n" @@ -147,7 +148,7 @@ private: else if(request_.target() == "/time") { response_.set(http::field::content_type, "text/html"); - boost::beast::ostream(response_.body()) + beast::ostream(response_.body()) << "\n" << "Current time\n" << "\n" @@ -162,7 +163,7 @@ private: { response_.result(http::status::not_found); response_.set(http::field::content_type, "text/plain"); - boost::beast::ostream(response_.body()) << "File not found\r\n"; + beast::ostream(response_.body()) << "File not found\r\n"; } } @@ -177,7 +178,7 @@ private: http::async_write( socket_, response_, - [self](boost::beast::error_code ec, std::size_t) + [self](beast::error_code ec, std::size_t) { self->socket_.shutdown(tcp::socket::shutdown_send, ec); self->deadline_.cancel(); @@ -191,7 +192,7 @@ private: auto self = shared_from_this(); deadline_.async_wait( - [self](boost::beast::error_code ec) + [self](beast::error_code ec) { if(!ec) { @@ -207,7 +208,7 @@ void http_server(tcp::acceptor& acceptor, tcp::socket& socket) { acceptor.async_accept(socket, - [&](boost::beast::error_code ec) + [&](beast::error_code ec) { if(!ec) std::make_shared(std::move(socket))->start(); @@ -231,10 +232,10 @@ main(int argc, char* argv[]) return EXIT_FAILURE; } - auto const address = boost::asio::ip::make_address(argv[1]); + auto const address = net::ip::make_address(argv[1]); unsigned short port = static_cast(std::atoi(argv[2])); - boost::asio::io_context ioc{1}; + net::io_context ioc{1}; tcp::acceptor acceptor{ioc, {address, port}}; tcp::socket socket{ioc}; diff --git a/example/http/server/stackless-ssl/http_server_stackless_ssl.cpp b/example/http/server/stackless-ssl/http_server_stackless_ssl.cpp index 5c0207cb..5d46e3c9 100644 --- a/example/http/server/stackless-ssl/http_server_stackless_ssl.cpp +++ b/example/http/server/stackless-ssl/http_server_stackless_ssl.cpp @@ -33,20 +33,22 @@ #include #include -using tcp = boost::asio::ip::tcp; // from +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from namespace ssl = boost::asio::ssl; // from -namespace http = boost::beast::http; // from +using tcp = boost::asio::ip::tcp; // from // Return a reasonable mime type based on the extension of a file. -boost::beast::string_view -mime_type(boost::beast::string_view path) +beast::string_view +mime_type(beast::string_view path) { - using boost::beast::iequals; + using beast::iequals; auto const ext = [&path] { auto const pos = path.rfind("."); - if(pos == boost::beast::string_view::npos) - return boost::beast::string_view{}; + if(pos == beast::string_view::npos) + return beast::string_view{}; return path.substr(pos); }(); if(iequals(ext, ".htm")) return "text/html"; @@ -77,8 +79,8 @@ mime_type(boost::beast::string_view path) // The returned path is normalized for the platform. std::string path_cat( - boost::beast::string_view base, - boost::beast::string_view path) + beast::string_view base, + beast::string_view path) { if(base.empty()) return path.to_string(); @@ -109,13 +111,13 @@ template< class Send> void handle_request( - boost::beast::string_view doc_root, + beast::string_view doc_root, http::request>&& req, Send&& send) { // Returns a bad request response auto const bad_request = - [&req](boost::beast::string_view why) + [&req](beast::string_view why) { http::response res{http::status::bad_request, req.version()}; res.set(http::field::server, BOOST_BEAST_VERSION_STRING); @@ -128,7 +130,7 @@ handle_request( // Returns a not found response auto const not_found = - [&req](boost::beast::string_view target) + [&req](beast::string_view target) { http::response res{http::status::not_found, req.version()}; res.set(http::field::server, BOOST_BEAST_VERSION_STRING); @@ -141,7 +143,7 @@ handle_request( // Returns a server error response auto const server_error = - [&req](boost::beast::string_view what) + [&req](beast::string_view what) { http::response res{http::status::internal_server_error, req.version()}; res.set(http::field::server, BOOST_BEAST_VERSION_STRING); @@ -160,7 +162,7 @@ handle_request( // Request path must be absolute and not contain "..". if( req.target().empty() || req.target()[0] != '/' || - req.target().find("..") != boost::beast::string_view::npos) + req.target().find("..") != beast::string_view::npos) return send(bad_request("Illegal request-target")); // Build the path to the requested file @@ -169,12 +171,12 @@ handle_request( path.append("index.html"); // Attempt to open the file - boost::beast::error_code ec; + beast::error_code ec; http::file_body::value_type body; - body.open(path.c_str(), boost::beast::file_mode::scan, ec); + body.open(path.c_str(), beast::file_mode::scan, ec); // Handle the case where the file doesn't exist - if(ec == boost::system::errc::no_such_file_or_directory) + if(ec == beast::errc::no_such_file_or_directory) return send(not_found(req.target())); // Handle an unknown error @@ -211,14 +213,14 @@ handle_request( // Report a failure void -fail(boost::system::error_code ec, char const* what) +fail(beast::error_code ec, char const* what) { std::cerr << what << ": " << ec.message() << "\n"; } // Handles an HTTP server connection class session - : public boost::asio::coroutine + : public net::coroutine , public std::enable_shared_from_this { // This is the C++11 equivalent of a generic lambda. @@ -251,7 +253,7 @@ class session http::async_write( self_.stream_, *sp, - boost::asio::bind_executor( + net::bind_executor( self_.strand_, std::bind( &session::loop, @@ -264,9 +266,9 @@ class session tcp::socket socket_; ssl::stream stream_; - boost::asio::strand< - boost::asio::io_context::executor_type> strand_; - boost::beast::flat_buffer buffer_; + net::strand< + net::io_context::executor_type> strand_; + beast::flat_buffer buffer_; std::shared_ptr doc_root_; http::request req_; std::shared_ptr res_; @@ -297,7 +299,7 @@ public: #include void loop( - boost::system::error_code ec, + beast::error_code ec, std::size_t bytes_transferred, bool close) { @@ -307,7 +309,7 @@ public: // Perform the SSL handshake yield stream_.async_handshake( ssl::stream_base::server, - boost::asio::bind_executor( + net::bind_executor( strand_, std::bind( &session::loop, @@ -326,7 +328,7 @@ public: // Read a request yield http::async_read(stream_, buffer_, req_, - boost::asio::bind_executor( + net::bind_executor( strand_, std::bind( &session::loop, @@ -359,7 +361,7 @@ public: // Perform the SSL shutdown yield stream_.async_shutdown( - boost::asio::bind_executor( + net::bind_executor( strand_, std::bind( &session::loop, @@ -380,7 +382,7 @@ public: // Accepts incoming connections and launches the sessions class listener - : public boost::asio::coroutine + : public net::coroutine , public std::enable_shared_from_this { ssl::context& ctx_; @@ -390,7 +392,7 @@ class listener public: listener( - boost::asio::io_context& ioc, + net::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint, std::shared_ptr const& doc_root) @@ -399,7 +401,7 @@ public: , socket_(ioc) , doc_root_(doc_root) { - boost::system::error_code ec; + beast::error_code ec; // Open the acceptor acceptor_.open(endpoint.protocol(), ec); @@ -410,7 +412,7 @@ public: } // Allow address reuse - acceptor_.set_option(boost::asio::socket_base::reuse_address(true), ec); + acceptor_.set_option(net::socket_base::reuse_address(true), ec); if(ec) { fail(ec, "set_option"); @@ -427,7 +429,7 @@ public: // Start listening for connections acceptor_.listen( - boost::asio::socket_base::max_listen_connections, ec); + net::socket_base::max_listen_connections, ec); if(ec) { fail(ec, "listen"); @@ -446,7 +448,7 @@ public: #include void - loop(boost::system::error_code ec = {}) + loop(beast::error_code ec = {}) { reenter(*this) { @@ -489,13 +491,13 @@ int main(int argc, char* argv[]) " http-server-stackless-ssl 0.0.0.0 8080 . 1\n"; return EXIT_FAILURE; } - auto const address = boost::asio::ip::make_address(argv[1]); + auto const address = net::ip::make_address(argv[1]); auto const port = static_cast(std::atoi(argv[2])); auto const doc_root = std::make_shared(argv[3]); auto const threads = std::max(1, std::atoi(argv[4])); // The io_context is required for all I/O - boost::asio::io_context ioc{threads}; + net::io_context ioc{threads}; // The SSL context is required, and holds certificates ssl::context ctx{ssl::context::sslv23}; diff --git a/example/http/server/stackless/http_server_stackless.cpp b/example/http/server/stackless/http_server_stackless.cpp index 4d97d70d..005fb950 100644 --- a/example/http/server/stackless/http_server_stackless.cpp +++ b/example/http/server/stackless/http_server_stackless.cpp @@ -30,19 +30,21 @@ #include #include +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from using tcp = boost::asio::ip::tcp; // from -namespace http = boost::beast::http; // from // Return a reasonable mime type based on the extension of a file. -boost::beast::string_view -mime_type(boost::beast::string_view path) +beast::string_view +mime_type(beast::string_view path) { - using boost::beast::iequals; + using beast::iequals; auto const ext = [&path] { auto const pos = path.rfind("."); - if(pos == boost::beast::string_view::npos) - return boost::beast::string_view{}; + if(pos == beast::string_view::npos) + return beast::string_view{}; return path.substr(pos); }(); if(iequals(ext, ".htm")) return "text/html"; @@ -73,8 +75,8 @@ mime_type(boost::beast::string_view path) // The returned path is normalized for the platform. std::string path_cat( - boost::beast::string_view base, - boost::beast::string_view path) + beast::string_view base, + beast::string_view path) { if(base.empty()) return path.to_string(); @@ -105,13 +107,13 @@ template< class Send> void handle_request( - boost::beast::string_view doc_root, + beast::string_view doc_root, http::request>&& req, Send&& send) { // Returns a bad request response auto const bad_request = - [&req](boost::beast::string_view why) + [&req](beast::string_view why) { http::response res{http::status::bad_request, req.version()}; res.set(http::field::server, BOOST_BEAST_VERSION_STRING); @@ -124,7 +126,7 @@ handle_request( // Returns a not found response auto const not_found = - [&req](boost::beast::string_view target) + [&req](beast::string_view target) { http::response res{http::status::not_found, req.version()}; res.set(http::field::server, BOOST_BEAST_VERSION_STRING); @@ -137,7 +139,7 @@ handle_request( // Returns a server error response auto const server_error = - [&req](boost::beast::string_view what) + [&req](beast::string_view what) { http::response res{http::status::internal_server_error, req.version()}; res.set(http::field::server, BOOST_BEAST_VERSION_STRING); @@ -156,7 +158,7 @@ handle_request( // Request path must be absolute and not contain "..". if( req.target().empty() || req.target()[0] != '/' || - req.target().find("..") != boost::beast::string_view::npos) + req.target().find("..") != beast::string_view::npos) return send(bad_request("Illegal request-target")); // Build the path to the requested file @@ -165,12 +167,12 @@ handle_request( path.append("index.html"); // Attempt to open the file - boost::beast::error_code ec; + beast::error_code ec; http::file_body::value_type body; - body.open(path.c_str(), boost::beast::file_mode::scan, ec); + body.open(path.c_str(), beast::file_mode::scan, ec); // Handle the case where the file doesn't exist - if(ec == boost::system::errc::no_such_file_or_directory) + if(ec == beast::errc::no_such_file_or_directory) return send(not_found(req.target())); // Handle an unknown error @@ -207,14 +209,14 @@ handle_request( // Report a failure void -fail(boost::system::error_code ec, char const* what) +fail(beast::error_code ec, char const* what) { std::cerr << what << ": " << ec.message() << "\n"; } // Handles an HTTP server connection class session - : public boost::asio::coroutine + : public net::coroutine , public std::enable_shared_from_this { // This is the C++11 equivalent of a generic lambda. @@ -248,7 +250,7 @@ class session http::async_write( self_.socket_, *sp, - boost::asio::bind_executor( + net::bind_executor( self_.strand_, std::bind( &session::loop, @@ -260,9 +262,9 @@ class session }; tcp::socket socket_; - boost::asio::strand< - boost::asio::io_context::executor_type> strand_; - boost::beast::flat_buffer buffer_; + net::strand< + net::io_context::executor_type> strand_; + beast::flat_buffer buffer_; std::shared_ptr doc_root_; http::request req_; std::shared_ptr res_; @@ -291,7 +293,7 @@ public: #include void loop( - boost::system::error_code ec, + beast::error_code ec, std::size_t bytes_transferred, bool close) { @@ -306,7 +308,7 @@ public: // Read a request yield http::async_read(socket_, buffer_, req_, - boost::asio::bind_executor( + net::bind_executor( strand_, std::bind( &session::loop, @@ -350,7 +352,7 @@ public: // Accepts incoming connections and launches the sessions class listener - : public boost::asio::coroutine + : public net::coroutine , public std::enable_shared_from_this { tcp::acceptor acceptor_; @@ -359,14 +361,14 @@ class listener public: listener( - boost::asio::io_context& ioc, + net::io_context& ioc, tcp::endpoint endpoint, std::shared_ptr const& doc_root) : acceptor_(ioc) , socket_(ioc) , doc_root_(doc_root) { - boost::system::error_code ec; + beast::error_code ec; // Open the acceptor acceptor_.open(endpoint.protocol(), ec); @@ -377,7 +379,7 @@ public: } // Allow address reuse - acceptor_.set_option(boost::asio::socket_base::reuse_address(true), ec); + acceptor_.set_option(net::socket_base::reuse_address(true), ec); if(ec) { fail(ec, "set_option"); @@ -393,7 +395,7 @@ public: } // Start listening for connections - acceptor_.listen(boost::asio::socket_base::max_listen_connections, ec); + acceptor_.listen(net::socket_base::max_listen_connections, ec); if(ec) { fail(ec, "listen"); @@ -412,7 +414,7 @@ public: #include void - loop(boost::system::error_code ec = {}) + loop(beast::error_code ec = {}) { reenter(*this) { @@ -454,13 +456,13 @@ int main(int argc, char* argv[]) " http-server-stackless 0.0.0.0 8080 . 1\n"; return EXIT_FAILURE; } - auto const address = boost::asio::ip::make_address(argv[1]); + auto const address = net::ip::make_address(argv[1]); auto const port = static_cast(std::atoi(argv[2])); auto const doc_root = std::make_shared(argv[3]); auto const threads = std::max(1, std::atoi(argv[4])); // The io_context is required for all I/O - boost::asio::io_context ioc{threads}; + net::io_context ioc{threads}; // Create and launch a listening port std::make_shared( diff --git a/example/http/server/sync-ssl/http_server_sync_ssl.cpp b/example/http/server/sync-ssl/http_server_sync_ssl.cpp index 76b9d8df..9b66b4ba 100644 --- a/example/http/server/sync-ssl/http_server_sync_ssl.cpp +++ b/example/http/server/sync-ssl/http_server_sync_ssl.cpp @@ -27,20 +27,22 @@ #include #include -using tcp = boost::asio::ip::tcp; // from +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from namespace ssl = boost::asio::ssl; // from -namespace http = boost::beast::http; // from +using tcp = boost::asio::ip::tcp; // from // Return a reasonable mime type based on the extension of a file. -boost::beast::string_view -mime_type(boost::beast::string_view path) +beast::string_view +mime_type(beast::string_view path) { - using boost::beast::iequals; + using beast::iequals; auto const ext = [&path] { auto const pos = path.rfind("."); - if(pos == boost::beast::string_view::npos) - return boost::beast::string_view{}; + if(pos == beast::string_view::npos) + return beast::string_view{}; return path.substr(pos); }(); if(iequals(ext, ".htm")) return "text/html"; @@ -71,8 +73,8 @@ mime_type(boost::beast::string_view path) // The returned path is normalized for the platform. std::string path_cat( - boost::beast::string_view base, - boost::beast::string_view path) + beast::string_view base, + beast::string_view path) { if(base.empty()) return path.to_string(); @@ -103,13 +105,13 @@ template< class Send> void handle_request( - boost::beast::string_view doc_root, + beast::string_view doc_root, http::request>&& req, Send&& send) { // Returns a bad request response auto const bad_request = - [&req](boost::beast::string_view why) + [&req](beast::string_view why) { http::response res{http::status::bad_request, req.version()}; res.set(http::field::server, BOOST_BEAST_VERSION_STRING); @@ -122,7 +124,7 @@ handle_request( // Returns a not found response auto const not_found = - [&req](boost::beast::string_view target) + [&req](beast::string_view target) { http::response res{http::status::not_found, req.version()}; res.set(http::field::server, BOOST_BEAST_VERSION_STRING); @@ -135,7 +137,7 @@ handle_request( // Returns a server error response auto const server_error = - [&req](boost::beast::string_view what) + [&req](beast::string_view what) { http::response res{http::status::internal_server_error, req.version()}; res.set(http::field::server, BOOST_BEAST_VERSION_STRING); @@ -154,7 +156,7 @@ handle_request( // Request path must be absolute and not contain "..". if( req.target().empty() || req.target()[0] != '/' || - req.target().find("..") != boost::beast::string_view::npos) + req.target().find("..") != beast::string_view::npos) return send(bad_request("Illegal request-target")); // Build the path to the requested file @@ -163,12 +165,12 @@ handle_request( path.append("index.html"); // Attempt to open the file - boost::beast::error_code ec; + beast::error_code ec; http::file_body::value_type body; - body.open(path.c_str(), boost::beast::file_mode::scan, ec); + body.open(path.c_str(), beast::file_mode::scan, ec); // Handle the case where the file doesn't exist - if(ec == boost::system::errc::no_such_file_or_directory) + if(ec == beast::errc::no_such_file_or_directory) return send(not_found(req.target())); // Handle an unknown error @@ -205,7 +207,7 @@ handle_request( // Report a failure void -fail(boost::system::error_code ec, char const* what) +fail(beast::error_code ec, char const* what) { std::cerr << what << ": " << ec.message() << "\n"; } @@ -217,13 +219,13 @@ struct send_lambda { Stream& stream_; bool& close_; - boost::system::error_code& ec_; + beast::error_code& ec_; explicit send_lambda( Stream& stream, bool& close, - boost::system::error_code& ec) + beast::error_code& ec) : stream_(stream) , close_(close) , ec_(ec) @@ -253,7 +255,7 @@ do_session( std::shared_ptr const& doc_root) { bool close = false; - boost::system::error_code ec; + beast::error_code ec; // Construct the stream around the socket ssl::stream stream{socket, ctx}; @@ -264,7 +266,7 @@ do_session( return fail(ec, "handshake"); // This buffer is required to persist across reads - boost::beast::flat_buffer buffer; + beast::flat_buffer buffer; // This lambda is used to send messages send_lambda> lambda{stream, close, ec}; @@ -314,12 +316,12 @@ int main(int argc, char* argv[]) " http-server-sync-ssl 0.0.0.0 8080 .\n"; return EXIT_FAILURE; } - auto const address = boost::asio::ip::make_address(argv[1]); + auto const address = net::ip::make_address(argv[1]); auto const port = static_cast(std::atoi(argv[2])); auto const doc_root = std::make_shared(argv[3]); // The io_context is required for all I/O - boost::asio::io_context ioc{1}; + net::io_context ioc{1}; // The SSL context is required, and holds certificates ssl::context ctx{ssl::context::sslv23}; diff --git a/example/http/server/sync/http_server_sync.cpp b/example/http/server/sync/http_server_sync.cpp index 31b1a14d..c8d80e43 100644 --- a/example/http/server/sync/http_server_sync.cpp +++ b/example/http/server/sync/http_server_sync.cpp @@ -24,21 +24,23 @@ #include #include +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace net = boost::asio; // from using tcp = boost::asio::ip::tcp; // from -namespace http = boost::beast::http; // from //------------------------------------------------------------------------------ // Return a reasonable mime type based on the extension of a file. -boost::beast::string_view -mime_type(boost::beast::string_view path) +beast::string_view +mime_type(beast::string_view path) { - using boost::beast::iequals; + using beast::iequals; auto const ext = [&path] { auto const pos = path.rfind("."); - if(pos == boost::beast::string_view::npos) - return boost::beast::string_view{}; + if(pos == beast::string_view::npos) + return beast::string_view{}; return path.substr(pos); }(); if(iequals(ext, ".htm")) return "text/html"; @@ -69,8 +71,8 @@ mime_type(boost::beast::string_view path) // The returned path is normalized for the platform. std::string path_cat( - boost::beast::string_view base, - boost::beast::string_view path) + beast::string_view base, + beast::string_view path) { if(base.empty()) return path.to_string(); @@ -101,13 +103,13 @@ template< class Send> void handle_request( - boost::beast::string_view doc_root, + beast::string_view doc_root, http::request>&& req, Send&& send) { // Returns a bad request response auto const bad_request = - [&req](boost::beast::string_view why) + [&req](beast::string_view why) { http::response res{http::status::bad_request, req.version()}; res.set(http::field::server, BOOST_BEAST_VERSION_STRING); @@ -120,7 +122,7 @@ handle_request( // Returns a not found response auto const not_found = - [&req](boost::beast::string_view target) + [&req](beast::string_view target) { http::response res{http::status::not_found, req.version()}; res.set(http::field::server, BOOST_BEAST_VERSION_STRING); @@ -133,7 +135,7 @@ handle_request( // Returns a server error response auto const server_error = - [&req](boost::beast::string_view what) + [&req](beast::string_view what) { http::response res{http::status::internal_server_error, req.version()}; res.set(http::field::server, BOOST_BEAST_VERSION_STRING); @@ -152,7 +154,7 @@ handle_request( // Request path must be absolute and not contain "..". if( req.target().empty() || req.target()[0] != '/' || - req.target().find("..") != boost::beast::string_view::npos) + req.target().find("..") != beast::string_view::npos) return send(bad_request("Illegal request-target")); // Build the path to the requested file @@ -161,12 +163,12 @@ handle_request( path.append("index.html"); // Attempt to open the file - boost::beast::error_code ec; + beast::error_code ec; http::file_body::value_type body; - body.open(path.c_str(), boost::beast::file_mode::scan, ec); + body.open(path.c_str(), beast::file_mode::scan, ec); // Handle the case where the file doesn't exist - if(ec == boost::system::errc::no_such_file_or_directory) + if(ec == beast::errc::no_such_file_or_directory) return send(not_found(req.target())); // Handle an unknown error @@ -203,7 +205,7 @@ handle_request( // Report a failure void -fail(boost::system::error_code ec, char const* what) +fail(beast::error_code ec, char const* what) { std::cerr << what << ": " << ec.message() << "\n"; } @@ -215,13 +217,13 @@ struct send_lambda { Stream& stream_; bool& close_; - boost::system::error_code& ec_; + beast::error_code& ec_; explicit send_lambda( Stream& stream, bool& close, - boost::system::error_code& ec) + beast::error_code& ec) : stream_(stream) , close_(close) , ec_(ec) @@ -250,10 +252,10 @@ do_session( std::shared_ptr const& doc_root) { bool close = false; - boost::system::error_code ec; + beast::error_code ec; // This buffer is required to persist across reads - boost::beast::flat_buffer buffer; + beast::flat_buffer buffer; // This lambda is used to send messages send_lambda lambda{socket, close, ec}; @@ -301,12 +303,12 @@ int main(int argc, char* argv[]) " http-server-sync 0.0.0.0 8080 .\n"; return EXIT_FAILURE; } - auto const address = boost::asio::ip::make_address(argv[1]); + auto const address = net::ip::make_address(argv[1]); auto const port = static_cast(std::atoi(argv[2])); auto const doc_root = std::make_shared(argv[3]); // The io_context is required for all I/O - boost::asio::io_context ioc{1}; + net::io_context ioc{1}; // The acceptor receives incoming connections tcp::acceptor acceptor{ioc, {address, port}}; diff --git a/example/websocket/client/async-ssl/websocket_client_async_ssl.cpp b/example/websocket/client/async-ssl/websocket_client_async_ssl.cpp index 9c4dfc35..a29fc8da 100644 --- a/example/websocket/client/async-ssl/websocket_client_async_ssl.cpp +++ b/example/websocket/client/async-ssl/websocket_client_async_ssl.cpp @@ -27,15 +27,18 @@ #include #include -using tcp = boost::asio::ip::tcp; // from -namespace ssl = boost::asio::ssl; // from -namespace websocket = boost::beast::websocket; // from +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = boost::asio::ip::tcp; // from //------------------------------------------------------------------------------ // Report a failure void -fail(boost::system::error_code ec, char const* what) +fail(beast::error_code ec, char const* what) { std::cerr << what << ": " << ec.message() << "\n"; } @@ -45,14 +48,14 @@ class session : public std::enable_shared_from_this { tcp::resolver resolver_; websocket::stream> ws_; - boost::beast::multi_buffer buffer_; + beast::multi_buffer buffer_; std::string host_; std::string text_; public: // Resolver and socket require an io_context explicit - session(boost::asio::io_context& ioc, ssl::context& ctx) + session(net::io_context& ioc, ssl::context& ctx) : resolver_(ioc) , ws_(ioc, ctx) { @@ -82,14 +85,14 @@ public: void on_resolve( - boost::system::error_code ec, + beast::error_code ec, tcp::resolver::results_type results) { if(ec) return fail(ec, "resolve"); // Make the connection on the IP address we get from a lookup - boost::asio::async_connect( + net::async_connect( ws_.next_layer().next_layer(), results.begin(), results.end(), @@ -100,7 +103,7 @@ public: } void - on_connect(boost::system::error_code ec) + on_connect(beast::error_code ec) { if(ec) return fail(ec, "connect"); @@ -115,7 +118,7 @@ public: } void - on_ssl_handshake(boost::system::error_code ec) + on_ssl_handshake(beast::error_code ec) { if(ec) return fail(ec, "ssl_handshake"); @@ -129,14 +132,14 @@ public: } void - on_handshake(boost::system::error_code ec) + on_handshake(beast::error_code ec) { if(ec) return fail(ec, "handshake"); // Send the message ws_.async_write( - boost::asio::buffer(text_), + net::buffer(text_), std::bind( &session::on_write, shared_from_this(), @@ -146,7 +149,7 @@ public: void on_write( - boost::system::error_code ec, + beast::error_code ec, std::size_t bytes_transferred) { boost::ignore_unused(bytes_transferred); @@ -166,7 +169,7 @@ public: void on_read( - boost::system::error_code ec, + beast::error_code ec, std::size_t bytes_transferred) { boost::ignore_unused(bytes_transferred); @@ -183,7 +186,7 @@ public: } void - on_close(boost::system::error_code ec) + on_close(beast::error_code ec) { if(ec) return fail(ec, "close"); @@ -191,7 +194,7 @@ public: // If we get here then the connection is closed gracefully // The buffers() function helps print a ConstBufferSequence - std::cout << boost::beast::buffers(buffer_.data()) << std::endl; + std::cout << beast::buffers(buffer_.data()) << std::endl; } }; @@ -213,7 +216,7 @@ int main(int argc, char** argv) auto const text = argv[3]; // The io_context is required for all I/O - boost::asio::io_context ioc; + net::io_context ioc; // The SSL context is required, and holds certificates ssl::context ctx{ssl::context::sslv23_client}; diff --git a/example/websocket/client/async/websocket_client_async.cpp b/example/websocket/client/async/websocket_client_async.cpp index 98505dd1..2e95bdab 100644 --- a/example/websocket/client/async/websocket_client_async.cpp +++ b/example/websocket/client/async/websocket_client_async.cpp @@ -23,14 +23,17 @@ #include #include -using tcp = boost::asio::ip::tcp; // from -namespace websocket = boost::beast::websocket; // from +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +using tcp = boost::asio::ip::tcp; // from //------------------------------------------------------------------------------ // Report a failure void -fail(boost::system::error_code ec, char const* what) +fail(beast::error_code ec, char const* what) { std::cerr << what << ": " << ec.message() << "\n"; } @@ -40,14 +43,14 @@ class session : public std::enable_shared_from_this { tcp::resolver resolver_; websocket::stream ws_; - boost::beast::multi_buffer buffer_; + beast::multi_buffer buffer_; std::string host_; std::string text_; public: // Resolver and socket require an io_context explicit - session(boost::asio::io_context& ioc) + session(net::io_context& ioc) : resolver_(ioc) , ws_(ioc) { @@ -77,14 +80,14 @@ public: void on_resolve( - boost::system::error_code ec, + beast::error_code ec, tcp::resolver::results_type results) { if(ec) return fail(ec, "resolve"); // Make the connection on the IP address we get from a lookup - boost::asio::async_connect( + net::async_connect( ws_.next_layer(), results.begin(), results.end(), @@ -95,7 +98,7 @@ public: } void - on_connect(boost::system::error_code ec) + on_connect(beast::error_code ec) { if(ec) return fail(ec, "connect"); @@ -109,14 +112,14 @@ public: } void - on_handshake(boost::system::error_code ec) + on_handshake(beast::error_code ec) { if(ec) return fail(ec, "handshake"); // Send the message ws_.async_write( - boost::asio::buffer(text_), + net::buffer(text_), std::bind( &session::on_write, shared_from_this(), @@ -126,7 +129,7 @@ public: void on_write( - boost::system::error_code ec, + beast::error_code ec, std::size_t bytes_transferred) { boost::ignore_unused(bytes_transferred); @@ -146,7 +149,7 @@ public: void on_read( - boost::system::error_code ec, + beast::error_code ec, std::size_t bytes_transferred) { boost::ignore_unused(bytes_transferred); @@ -163,7 +166,7 @@ public: } void - on_close(boost::system::error_code ec) + on_close(beast::error_code ec) { if(ec) return fail(ec, "close"); @@ -171,7 +174,7 @@ public: // If we get here then the connection is closed gracefully // The buffers() function helps print a ConstBufferSequence - std::cout << boost::beast::buffers(buffer_.data()) << std::endl; + std::cout << beast::buffers(buffer_.data()) << std::endl; } }; @@ -193,7 +196,7 @@ int main(int argc, char** argv) auto const text = argv[3]; // The io_context is required for all I/O - boost::asio::io_context ioc; + net::io_context ioc; // Launch the asynchronous operation std::make_shared(ioc)->run(host, port, text); diff --git a/example/websocket/client/coro-ssl/websocket_client_coro_ssl.cpp b/example/websocket/client/coro-ssl/websocket_client_coro_ssl.cpp index c5c5cb94..322e5a31 100644 --- a/example/websocket/client/coro-ssl/websocket_client_coro_ssl.cpp +++ b/example/websocket/client/coro-ssl/websocket_client_coro_ssl.cpp @@ -27,15 +27,18 @@ #include #include -using tcp = boost::asio::ip::tcp; // from -namespace ssl = boost::asio::ssl; // from -namespace websocket = boost::beast::websocket; // from +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = boost::asio::ip::tcp; // from //------------------------------------------------------------------------------ // Report a failure void -fail(boost::system::error_code ec, char const* what) +fail(beast::error_code ec, char const* what) { std::cerr << what << ": " << ec.message() << "\n"; } @@ -46,11 +49,11 @@ do_session( std::string const& host, std::string const& port, std::string const& text, - boost::asio::io_context& ioc, + net::io_context& ioc, ssl::context& ctx, - boost::asio::yield_context yield) + net::yield_context yield) { - boost::system::error_code ec; + beast::error_code ec; // These objects perform our I/O tcp::resolver resolver{ioc}; @@ -62,7 +65,7 @@ do_session( return fail(ec, "resolve"); // Make the connection on the IP address we get from a lookup - boost::asio::async_connect(ws.next_layer().next_layer(), results.begin(), results.end(), yield[ec]); + net::async_connect(ws.next_layer().next_layer(), results.begin(), results.end(), yield[ec]); if(ec) return fail(ec, "connect"); @@ -77,12 +80,12 @@ do_session( return fail(ec, "handshake"); // Send the message - ws.async_write(boost::asio::buffer(std::string(text)), yield[ec]); + ws.async_write(net::buffer(std::string(text)), yield[ec]); if(ec) return fail(ec, "write"); // This buffer will hold the incoming message - boost::beast::multi_buffer b; + beast::multi_buffer b; // Read a message into our buffer ws.async_read(b, yield[ec]); @@ -97,7 +100,7 @@ do_session( // If we get here then the connection is closed gracefully // The buffers() function helps print a ConstBufferSequence - std::cout << boost::beast::buffers(b.data()) << std::endl; + std::cout << beast::buffers(b.data()) << std::endl; } //------------------------------------------------------------------------------ @@ -118,7 +121,7 @@ int main(int argc, char** argv) auto const text = argv[3]; // The io_context is required for all I/O - boost::asio::io_context ioc; + net::io_context ioc; // The SSL context is required, and holds certificates ssl::context ctx{ssl::context::sslv23_client}; @@ -127,7 +130,7 @@ int main(int argc, char** argv) load_root_certificates(ctx); // Launch the asynchronous operation - boost::asio::spawn(ioc, std::bind( + net::spawn(ioc, std::bind( &do_session, std::string(host), std::string(port), diff --git a/example/websocket/client/coro/websocket_client_coro.cpp b/example/websocket/client/coro/websocket_client_coro.cpp index d88d8259..f9e82efb 100644 --- a/example/websocket/client/coro/websocket_client_coro.cpp +++ b/example/websocket/client/coro/websocket_client_coro.cpp @@ -23,14 +23,17 @@ #include #include -using tcp = boost::asio::ip::tcp; // from -namespace websocket = boost::beast::websocket; // from +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +using tcp = boost::asio::ip::tcp; // from //------------------------------------------------------------------------------ // Report a failure void -fail(boost::system::error_code ec, char const* what) +fail(beast::error_code ec, char const* what) { std::cerr << what << ": " << ec.message() << "\n"; } @@ -41,10 +44,10 @@ do_session( std::string const& host, std::string const& port, std::string const& text, - boost::asio::io_context& ioc, - boost::asio::yield_context yield) + net::io_context& ioc, + net::yield_context yield) { - boost::system::error_code ec; + beast::error_code ec; // These objects perform our I/O tcp::resolver resolver{ioc}; @@ -56,7 +59,7 @@ do_session( return fail(ec, "resolve"); // Make the connection on the IP address we get from a lookup - boost::asio::async_connect(ws.next_layer(), results.begin(), results.end(), yield[ec]); + net::async_connect(ws.next_layer(), results.begin(), results.end(), yield[ec]); if(ec) return fail(ec, "connect"); @@ -66,12 +69,12 @@ do_session( return fail(ec, "handshake"); // Send the message - ws.async_write(boost::asio::buffer(std::string(text)), yield[ec]); + ws.async_write(net::buffer(std::string(text)), yield[ec]); if(ec) return fail(ec, "write"); // This buffer will hold the incoming message - boost::beast::multi_buffer b; + beast::multi_buffer b; // Read a message into our buffer ws.async_read(b, yield[ec]); @@ -86,7 +89,7 @@ do_session( // If we get here then the connection is closed gracefully // The buffers() function helps print a ConstBufferSequence - std::cout << boost::beast::buffers(b.data()) << std::endl; + std::cout << beast::buffers(b.data()) << std::endl; } //------------------------------------------------------------------------------ @@ -107,10 +110,10 @@ int main(int argc, char** argv) auto const text = argv[3]; // The io_context is required for all I/O - boost::asio::io_context ioc; + net::io_context ioc; // Launch the asynchronous operation - boost::asio::spawn(ioc, std::bind( + net::spawn(ioc, std::bind( &do_session, std::string(host), std::string(port), diff --git a/example/websocket/client/sync-ssl/websocket_client_sync_ssl.cpp b/example/websocket/client/sync-ssl/websocket_client_sync_ssl.cpp index d4bbe95d..b83e51d7 100644 --- a/example/websocket/client/sync-ssl/websocket_client_sync_ssl.cpp +++ b/example/websocket/client/sync-ssl/websocket_client_sync_ssl.cpp @@ -25,9 +25,12 @@ #include #include -using tcp = boost::asio::ip::tcp; // from -namespace ssl = boost::asio::ssl; // from -namespace websocket = boost::beast::websocket; // from +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = boost::asio::ip::tcp; // from // Sends a WebSocket message and prints the response int main(int argc, char** argv) @@ -48,7 +51,7 @@ int main(int argc, char** argv) auto const text = argv[3]; // The io_context is required for all I/O - boost::asio::io_context ioc; + net::io_context ioc; // The SSL context is required, and holds certificates ssl::context ctx{ssl::context::sslv23_client}; @@ -64,7 +67,7 @@ int main(int argc, char** argv) auto const results = resolver.resolve(host, port); // Make the connection on the IP address we get from a lookup - boost::asio::connect(ws.next_layer().next_layer(), results.begin(), results.end()); + net::connect(ws.next_layer().next_layer(), results.begin(), results.end()); // Perform the SSL handshake ws.next_layer().handshake(ssl::stream_base::client); @@ -73,10 +76,10 @@ int main(int argc, char** argv) ws.handshake(host, "/"); // Send the message - ws.write(boost::asio::buffer(std::string(text))); + ws.write(net::buffer(std::string(text))); // This buffer will hold the incoming message - boost::beast::multi_buffer b; + beast::multi_buffer b; // Read a message into our buffer ws.read(b); @@ -87,7 +90,7 @@ int main(int argc, char** argv) // If we get here then the connection is closed gracefully // The buffers() function helps print a ConstBufferSequence - std::cout << boost::beast::buffers(b.data()) << std::endl; + std::cout << beast::buffers(b.data()) << std::endl; } catch(std::exception const& e) { diff --git a/example/websocket/client/sync/websocket_client_sync.cpp b/example/websocket/client/sync/websocket_client_sync.cpp index bde16c56..6543d6ed 100644 --- a/example/websocket/client/sync/websocket_client_sync.cpp +++ b/example/websocket/client/sync/websocket_client_sync.cpp @@ -23,8 +23,11 @@ #include #include -using tcp = boost::asio::ip::tcp; // from -namespace websocket = boost::beast::websocket; // from +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +using tcp = boost::asio::ip::tcp; // from // Sends a WebSocket message and prints the response int main(int argc, char** argv) @@ -45,7 +48,7 @@ int main(int argc, char** argv) auto const text = argv[3]; // The io_context is required for all I/O - boost::asio::io_context ioc; + net::io_context ioc; // These objects perform our I/O tcp::resolver resolver{ioc}; @@ -55,16 +58,16 @@ int main(int argc, char** argv) auto const results = resolver.resolve(host, port); // Make the connection on the IP address we get from a lookup - boost::asio::connect(ws.next_layer(), results.begin(), results.end()); + net::connect(ws.next_layer(), results.begin(), results.end()); // Perform the websocket handshake ws.handshake(host, "/"); // Send the message - ws.write(boost::asio::buffer(std::string(text))); + ws.write(net::buffer(std::string(text))); // This buffer will hold the incoming message - boost::beast::multi_buffer buffer; + beast::multi_buffer buffer; // Read a message into our buffer ws.read(buffer); @@ -75,7 +78,7 @@ int main(int argc, char** argv) // If we get here then the connection is closed gracefully // The buffers() function helps print a ConstBufferSequence - std::cout << boost::beast::buffers(buffer.data()) << std::endl; + std::cout << beast::buffers(buffer.data()) << std::endl; } catch(std::exception const& e) { diff --git a/example/websocket/server/async-ssl/websocket_server_async_ssl.cpp b/example/websocket/server/async-ssl/websocket_server_async_ssl.cpp index 3ad58550..3753d2fa 100644 --- a/example/websocket/server/async-ssl/websocket_server_async_ssl.cpp +++ b/example/websocket/server/async-ssl/websocket_server_async_ssl.cpp @@ -31,15 +31,18 @@ #include #include -using tcp = boost::asio::ip::tcp; // from -namespace ssl = boost::asio::ssl; // from -namespace websocket = boost::beast::websocket; // from +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = boost::asio::ip::tcp; // from //------------------------------------------------------------------------------ // Report a failure void -fail(boost::system::error_code ec, char const* what) +fail(beast::error_code ec, char const* what) { std::cerr << what << ": " << ec.message() << "\n"; } @@ -49,9 +52,9 @@ class session : public std::enable_shared_from_this { tcp::socket socket_; websocket::stream> ws_; - boost::asio::strand< - boost::asio::io_context::executor_type> strand_; - boost::beast::multi_buffer buffer_; + net::strand< + net::io_context::executor_type> strand_; + beast::multi_buffer buffer_; public: // Take ownership of the socket @@ -69,7 +72,7 @@ public: // Perform the SSL handshake ws_.next_layer().async_handshake( ssl::stream_base::server, - boost::asio::bind_executor( + net::bind_executor( strand_, std::bind( &session::on_handshake, @@ -78,14 +81,14 @@ public: } void - on_handshake(boost::system::error_code ec) + on_handshake(beast::error_code ec) { if(ec) return fail(ec, "handshake"); // Accept the websocket handshake ws_.async_accept( - boost::asio::bind_executor( + net::bind_executor( strand_, std::bind( &session::on_accept, @@ -94,7 +97,7 @@ public: } void - on_accept(boost::system::error_code ec) + on_accept(beast::error_code ec) { if(ec) return fail(ec, "accept"); @@ -109,7 +112,7 @@ public: // Read a message into our buffer ws_.async_read( buffer_, - boost::asio::bind_executor( + net::bind_executor( strand_, std::bind( &session::on_read, @@ -120,7 +123,7 @@ public: void on_read( - boost::system::error_code ec, + beast::error_code ec, std::size_t bytes_transferred) { boost::ignore_unused(bytes_transferred); @@ -136,7 +139,7 @@ public: ws_.text(ws_.got_text()); ws_.async_write( buffer_.data(), - boost::asio::bind_executor( + net::bind_executor( strand_, std::bind( &session::on_write, @@ -147,7 +150,7 @@ public: void on_write( - boost::system::error_code ec, + beast::error_code ec, std::size_t bytes_transferred) { boost::ignore_unused(bytes_transferred); @@ -174,14 +177,14 @@ class listener : public std::enable_shared_from_this public: listener( - boost::asio::io_context& ioc, + net::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint) : ctx_(ctx) , acceptor_(ioc) , socket_(ioc) { - boost::system::error_code ec; + beast::error_code ec; // Open the acceptor acceptor_.open(endpoint.protocol(), ec); @@ -192,7 +195,7 @@ public: } // Allow address reuse - acceptor_.set_option(boost::asio::socket_base::reuse_address(true), ec); + acceptor_.set_option(net::socket_base::reuse_address(true), ec); if(ec) { fail(ec, "set_option"); @@ -209,7 +212,7 @@ public: // Start listening for connections acceptor_.listen( - boost::asio::socket_base::max_listen_connections, ec); + net::socket_base::max_listen_connections, ec); if(ec) { fail(ec, "listen"); @@ -238,7 +241,7 @@ public: } void - on_accept(boost::system::error_code ec) + on_accept(beast::error_code ec) { if(ec) { @@ -268,12 +271,12 @@ int main(int argc, char* argv[]) " websocket-server-async-ssl 0.0.0.0 8080 1\n"; return EXIT_FAILURE; } - auto const address = boost::asio::ip::make_address(argv[1]); + auto const address = net::ip::make_address(argv[1]); auto const port = static_cast(std::atoi(argv[2])); auto const threads = std::max(1, std::atoi(argv[3])); // The io_context is required for all I/O - boost::asio::io_context ioc{threads}; + net::io_context ioc{threads}; // The SSL context is required, and holds certificates ssl::context ctx{ssl::context::sslv23}; diff --git a/example/websocket/server/async/websocket_server_async.cpp b/example/websocket/server/async/websocket_server_async.cpp index f538777f..4ca3f318 100644 --- a/example/websocket/server/async/websocket_server_async.cpp +++ b/example/websocket/server/async/websocket_server_async.cpp @@ -27,14 +27,17 @@ #include #include -using tcp = boost::asio::ip::tcp; // from -namespace websocket = boost::beast::websocket; // from +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +using tcp = boost::asio::ip::tcp; // from //------------------------------------------------------------------------------ // Report a failure void -fail(boost::system::error_code ec, char const* what) +fail(beast::error_code ec, char const* what) { std::cerr << what << ": " << ec.message() << "\n"; } @@ -43,9 +46,9 @@ fail(boost::system::error_code ec, char const* what) class session : public std::enable_shared_from_this { websocket::stream ws_; - boost::asio::strand< - boost::asio::io_context::executor_type> strand_; - boost::beast::multi_buffer buffer_; + net::strand< + net::io_context::executor_type> strand_; + beast::multi_buffer buffer_; public: // Take ownership of the socket @@ -62,7 +65,7 @@ public: { // Accept the websocket handshake ws_.async_accept( - boost::asio::bind_executor( + net::bind_executor( strand_, std::bind( &session::on_accept, @@ -71,7 +74,7 @@ public: } void - on_accept(boost::system::error_code ec) + on_accept(beast::error_code ec) { if(ec) return fail(ec, "accept"); @@ -86,7 +89,7 @@ public: // Read a message into our buffer ws_.async_read( buffer_, - boost::asio::bind_executor( + net::bind_executor( strand_, std::bind( &session::on_read, @@ -97,7 +100,7 @@ public: void on_read( - boost::system::error_code ec, + beast::error_code ec, std::size_t bytes_transferred) { boost::ignore_unused(bytes_transferred); @@ -113,7 +116,7 @@ public: ws_.text(ws_.got_text()); ws_.async_write( buffer_.data(), - boost::asio::bind_executor( + net::bind_executor( strand_, std::bind( &session::on_write, @@ -124,7 +127,7 @@ public: void on_write( - boost::system::error_code ec, + beast::error_code ec, std::size_t bytes_transferred) { boost::ignore_unused(bytes_transferred); @@ -150,12 +153,12 @@ class listener : public std::enable_shared_from_this public: listener( - boost::asio::io_context& ioc, + net::io_context& ioc, tcp::endpoint endpoint) : acceptor_(ioc) , socket_(ioc) { - boost::system::error_code ec; + beast::error_code ec; // Open the acceptor acceptor_.open(endpoint.protocol(), ec); @@ -166,7 +169,7 @@ public: } // Allow address reuse - acceptor_.set_option(boost::asio::socket_base::reuse_address(true), ec); + acceptor_.set_option(net::socket_base::reuse_address(true), ec); if(ec) { fail(ec, "set_option"); @@ -183,7 +186,7 @@ public: // Start listening for connections acceptor_.listen( - boost::asio::socket_base::max_listen_connections, ec); + net::socket_base::max_listen_connections, ec); if(ec) { fail(ec, "listen"); @@ -212,7 +215,7 @@ public: } void - on_accept(boost::system::error_code ec) + on_accept(beast::error_code ec) { if(ec) { @@ -242,12 +245,12 @@ int main(int argc, char* argv[]) " websocket-server-async 0.0.0.0 8080 1\n"; return EXIT_FAILURE; } - auto const address = boost::asio::ip::make_address(argv[1]); + auto const address = net::ip::make_address(argv[1]); auto const port = static_cast(std::atoi(argv[2])); auto const threads = std::max(1, std::atoi(argv[3])); // The io_context is required for all I/O - boost::asio::io_context ioc{threads}; + net::io_context ioc{threads}; // Create and launch a listening port std::make_shared(ioc, tcp::endpoint{address, port})->run(); diff --git a/example/websocket/server/coro-ssl/websocket_server_coro_ssl.cpp b/example/websocket/server/coro-ssl/websocket_server_coro_ssl.cpp index 4fcefbed..b085f6ee 100644 --- a/example/websocket/server/coro-ssl/websocket_server_coro_ssl.cpp +++ b/example/websocket/server/coro-ssl/websocket_server_coro_ssl.cpp @@ -30,15 +30,18 @@ #include #include -using tcp = boost::asio::ip::tcp; // from -namespace ssl = boost::asio::ssl; // from -namespace websocket = boost::beast::websocket; // from +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = boost::asio::ip::tcp; // from //------------------------------------------------------------------------------ // Report a failure void -fail(boost::system::error_code ec, char const* what) +fail(beast::error_code ec, char const* what) { std::cerr << what << ": " << ec.message() << "\n"; } @@ -48,9 +51,9 @@ void do_session( tcp::socket& socket, ssl::context& ctx, - boost::asio::yield_context yield) + net::yield_context yield) { - boost::system::error_code ec; + beast::error_code ec; // Construct the stream by moving in the socket websocket::stream> ws{socket, ctx}; @@ -68,7 +71,7 @@ do_session( for(;;) { // This buffer will hold the incoming message - boost::beast::multi_buffer buffer; + beast::multi_buffer buffer; // Read a message ws.async_read(buffer, yield[ec]); @@ -93,12 +96,12 @@ do_session( // Accepts incoming connections and launches the sessions void do_listen( - boost::asio::io_context& ioc, + net::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint, - boost::asio::yield_context yield) + net::yield_context yield) { - boost::system::error_code ec; + beast::error_code ec; // Open the acceptor tcp::acceptor acceptor(ioc); @@ -107,7 +110,7 @@ do_listen( return fail(ec, "open"); // Allow address reuse - acceptor.set_option(boost::asio::socket_base::reuse_address(true), ec); + acceptor.set_option(net::socket_base::reuse_address(true), ec); if(ec) return fail(ec, "set_option"); @@ -117,7 +120,7 @@ do_listen( return fail(ec, "bind"); // Start listening for connections - acceptor.listen(boost::asio::socket_base::max_listen_connections, ec); + acceptor.listen(net::socket_base::max_listen_connections, ec); if(ec) return fail(ec, "listen"); @@ -128,7 +131,7 @@ do_listen( if(ec) fail(ec, "accept"); else - boost::asio::spawn( + net::spawn( acceptor.get_executor().context(), std::bind( &do_session, @@ -149,12 +152,12 @@ int main(int argc, char* argv[]) " websocket-server-coro-ssl 0.0.0.0 8080 1\n"; return EXIT_FAILURE; } - auto const address = boost::asio::ip::make_address(argv[1]); + auto const address = net::ip::make_address(argv[1]); auto const port = static_cast(std::atoi(argv[2])); auto const threads = std::max(1, std::atoi(argv[3])); // The io_context is required for all I/O - boost::asio::io_context ioc{threads}; + net::io_context ioc{threads}; // The SSL context is required, and holds certificates ssl::context ctx{ssl::context::sslv23}; @@ -163,7 +166,7 @@ int main(int argc, char* argv[]) load_server_certificate(ctx); // Spawn a listening port - boost::asio::spawn(ioc, + net::spawn(ioc, std::bind( &do_listen, std::ref(ioc), diff --git a/example/websocket/server/coro/websocket_server_coro.cpp b/example/websocket/server/coro/websocket_server_coro.cpp index 282d53aa..58ea4a37 100644 --- a/example/websocket/server/coro/websocket_server_coro.cpp +++ b/example/websocket/server/coro/websocket_server_coro.cpp @@ -26,23 +26,26 @@ #include #include -using tcp = boost::asio::ip::tcp; // from -namespace websocket = boost::beast::websocket; // from +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +using tcp = boost::asio::ip::tcp; // from //------------------------------------------------------------------------------ // Report a failure void -fail(boost::system::error_code ec, char const* what) +fail(beast::error_code ec, char const* what) { std::cerr << what << ": " << ec.message() << "\n"; } // Echoes back all received WebSocket messages void -do_session(tcp::socket& socket, boost::asio::yield_context yield) +do_session(tcp::socket& socket, net::yield_context yield) { - boost::system::error_code ec; + beast::error_code ec; // Construct the stream by moving in the socket websocket::stream ws{std::move(socket)}; @@ -55,7 +58,7 @@ do_session(tcp::socket& socket, boost::asio::yield_context yield) for(;;) { // This buffer will hold the incoming message - boost::beast::multi_buffer buffer; + beast::multi_buffer buffer; // Read a message ws.async_read(buffer, yield[ec]); @@ -80,11 +83,11 @@ do_session(tcp::socket& socket, boost::asio::yield_context yield) // Accepts incoming connections and launches the sessions void do_listen( - boost::asio::io_context& ioc, + net::io_context& ioc, tcp::endpoint endpoint, - boost::asio::yield_context yield) + net::yield_context yield) { - boost::system::error_code ec; + beast::error_code ec; // Open the acceptor tcp::acceptor acceptor(ioc); @@ -93,7 +96,7 @@ do_listen( return fail(ec, "open"); // Allow address reuse - acceptor.set_option(boost::asio::socket_base::reuse_address(true), ec); + acceptor.set_option(net::socket_base::reuse_address(true), ec); if(ec) return fail(ec, "set_option"); @@ -103,7 +106,7 @@ do_listen( return fail(ec, "bind"); // Start listening for connections - acceptor.listen(boost::asio::socket_base::max_listen_connections, ec); + acceptor.listen(net::socket_base::max_listen_connections, ec); if(ec) return fail(ec, "listen"); @@ -114,7 +117,7 @@ do_listen( if(ec) fail(ec, "accept"); else - boost::asio::spawn( + net::spawn( acceptor.get_executor().context(), std::bind( &do_session, @@ -134,15 +137,15 @@ int main(int argc, char* argv[]) " websocket-server-coro 0.0.0.0 8080 1\n"; return EXIT_FAILURE; } - auto const address = boost::asio::ip::make_address(argv[1]); + auto const address = net::ip::make_address(argv[1]); auto const port = static_cast(std::atoi(argv[2])); auto const threads = std::max(1, std::atoi(argv[3])); // The io_context is required for all I/O - boost::asio::io_context ioc{threads}; + net::io_context ioc{threads}; // Spawn a listening port - boost::asio::spawn(ioc, + net::spawn(ioc, std::bind( &do_listen, std::ref(ioc), diff --git a/example/websocket/server/fast/websocket_server_fast.cpp b/example/websocket/server/fast/websocket_server_fast.cpp index cbeeafa0..52ed2d29 100644 --- a/example/websocket/server/fast/websocket_server_fast.cpp +++ b/example/websocket/server/fast/websocket_server_fast.cpp @@ -43,15 +43,17 @@ #include #include -using tcp = boost::asio::ip::tcp; // from -namespace http = boost::beast::http; // from -namespace websocket = boost::beast::websocket; // from +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +using tcp = boost::asio::ip::tcp; // from //------------------------------------------------------------------------------ // Report a failure void -fail(boost::system::error_code ec, char const* what) +fail(beast::error_code ec, char const* what) { std::cerr << (std::string(what) + ": " + ec.message() + "\n"); } @@ -81,7 +83,7 @@ setup_stream(websocket::stream& ws) void do_sync_session(tcp::socket& socket) { - boost::system::error_code ec; + beast::error_code ec; websocket::stream ws{std::move(socket)}; setup_stream(ws); @@ -98,7 +100,7 @@ do_sync_session(tcp::socket& socket) for(;;) { - boost::beast::multi_buffer buffer; + beast::multi_buffer buffer; ws.read(buffer, ec); if(ec == websocket::error::closed) @@ -114,10 +116,10 @@ do_sync_session(tcp::socket& socket) void do_sync_listen( - boost::asio::io_context& ioc, + net::io_context& ioc, tcp::endpoint endpoint) { - boost::system::error_code ec; + beast::error_code ec; tcp::acceptor acceptor{ioc, endpoint}; for(;;) { @@ -139,9 +141,9 @@ do_sync_listen( class async_session : public std::enable_shared_from_this { websocket::stream ws_; - boost::asio::strand< - boost::asio::io_context::executor_type> strand_; - boost::beast::multi_buffer buffer_; + net::strand< + net::io_context::executor_type> strand_; + beast::multi_buffer buffer_; public: // Take ownership of the socket @@ -164,7 +166,7 @@ public: res.set(http::field::server, "Boost.Beast/" + std::to_string(BOOST_BEAST_VERSION) + "-Async"); }, - boost::asio::bind_executor( + net::bind_executor( strand_, std::bind( &async_session::on_accept, @@ -173,7 +175,7 @@ public: } void - on_accept(boost::system::error_code ec) + on_accept(beast::error_code ec) { if(ec) return fail(ec, "accept"); @@ -188,7 +190,7 @@ public: // Read a message into our buffer ws_.async_read( buffer_, - boost::asio::bind_executor( + net::bind_executor( strand_, std::bind( &async_session::on_read, @@ -199,7 +201,7 @@ public: void on_read( - boost::system::error_code ec, + beast::error_code ec, std::size_t bytes_transferred) { boost::ignore_unused(bytes_transferred); @@ -215,7 +217,7 @@ public: ws_.text(ws_.got_text()); ws_.async_write( buffer_.data(), - boost::asio::bind_executor( + net::bind_executor( strand_, std::bind( &async_session::on_write, @@ -226,7 +228,7 @@ public: void on_write( - boost::system::error_code ec, + beast::error_code ec, std::size_t bytes_transferred) { boost::ignore_unused(bytes_transferred); @@ -245,20 +247,20 @@ public: // Accepts incoming connections and launches the sessions class async_listener : public std::enable_shared_from_this { - boost::asio::strand< - boost::asio::io_context::executor_type> strand_; + net::strand< + net::io_context::executor_type> strand_; tcp::acceptor acceptor_; tcp::socket socket_; public: async_listener( - boost::asio::io_context& ioc, + net::io_context& ioc, tcp::endpoint endpoint) : strand_(ioc.get_executor()) , acceptor_(ioc) , socket_(ioc) { - boost::system::error_code ec; + beast::error_code ec; // Open the acceptor acceptor_.open(endpoint.protocol(), ec); @@ -269,7 +271,7 @@ public: } // Allow address reuse - acceptor_.set_option(boost::asio::socket_base::reuse_address(true), ec); + acceptor_.set_option(net::socket_base::reuse_address(true), ec); if(ec) { fail(ec, "set_option"); @@ -286,7 +288,7 @@ public: // Start listening for connections acceptor_.listen( - boost::asio::socket_base::max_listen_connections, ec); + net::socket_base::max_listen_connections, ec); if(ec) { fail(ec, "listen"); @@ -308,7 +310,7 @@ public: { acceptor_.async_accept( socket_, - boost::asio::bind_executor( + net::bind_executor( strand_, std::bind( &async_listener::on_accept, @@ -317,7 +319,7 @@ public: } void - on_accept(boost::system::error_code ec) + on_accept(beast::error_code ec) { if(ec) { @@ -337,9 +339,9 @@ public: //------------------------------------------------------------------------------ void -do_coro_session(tcp::socket& socket, boost::asio::yield_context yield) +do_coro_session(tcp::socket& socket, net::yield_context yield) { - boost::system::error_code ec; + beast::error_code ec; websocket::stream ws{std::move(socket)}; setup_stream(ws); @@ -356,7 +358,7 @@ do_coro_session(tcp::socket& socket, boost::asio::yield_context yield) for(;;) { - boost::beast::multi_buffer buffer; + beast::multi_buffer buffer; ws.async_read(buffer, yield[ec]); if(ec == websocket::error::closed) @@ -373,18 +375,18 @@ do_coro_session(tcp::socket& socket, boost::asio::yield_context yield) void do_coro_listen( - boost::asio::io_context& ioc, + net::io_context& ioc, tcp::endpoint endpoint, - boost::asio::yield_context yield) + net::yield_context yield) { - boost::system::error_code ec; + beast::error_code ec; tcp::acceptor acceptor(ioc); acceptor.open(endpoint.protocol(), ec); if(ec) return fail(ec, "open"); - acceptor.set_option(boost::asio::socket_base::reuse_address(true), ec); + acceptor.set_option(net::socket_base::reuse_address(true), ec); if(ec) return fail(ec, "set_option"); @@ -392,7 +394,7 @@ do_coro_listen( if(ec) return fail(ec, "bind"); - acceptor.listen(boost::asio::socket_base::max_listen_connections, ec); + acceptor.listen(net::socket_base::max_listen_connections, ec); if(ec) return fail(ec, "listen"); @@ -407,7 +409,7 @@ do_coro_listen( continue; } - boost::asio::spawn( + net::spawn( acceptor.get_executor().context(), std::bind( &do_coro_session, @@ -433,12 +435,12 @@ int main(int argc, char* argv[]) " starting-port+2 for coroutine.\n"; return EXIT_FAILURE; } - auto const address = boost::asio::ip::make_address(argv[1]); + auto const address = net::ip::make_address(argv[1]); auto const port = static_cast(std::atoi(argv[2])); auto const threads = std::max(1, std::atoi(argv[3])); // The io_context is required for all I/O - boost::asio::io_context ioc{threads}; + net::io_context ioc{threads}; // Create sync port std::thread(std::bind( @@ -457,7 +459,7 @@ int main(int argc, char* argv[]) static_cast(port + 1u)})->run(); // Create coro port - boost::asio::spawn(ioc, + net::spawn(ioc, std::bind( &do_coro_listen, std::ref(ioc), diff --git a/example/websocket/server/stackless-ssl/websocket_server_stackless_ssl.cpp b/example/websocket/server/stackless-ssl/websocket_server_stackless_ssl.cpp index be892e74..2f2d7a3c 100644 --- a/example/websocket/server/stackless-ssl/websocket_server_stackless_ssl.cpp +++ b/example/websocket/server/stackless-ssl/websocket_server_stackless_ssl.cpp @@ -32,29 +32,32 @@ #include #include -using tcp = boost::asio::ip::tcp; // from -namespace ssl = boost::asio::ssl; // from -namespace websocket = boost::beast::websocket; // from +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = boost::asio::ip::tcp; // from //------------------------------------------------------------------------------ // Report a failure void -fail(boost::system::error_code ec, char const* what) +fail(beast::error_code ec, char const* what) { std::cerr << what << ": " << ec.message() << "\n"; } // Echoes back all received WebSocket messages class session - : public boost::asio::coroutine + : public net::coroutine , public std::enable_shared_from_this { tcp::socket socket_; websocket::stream> ws_; - boost::asio::strand< - boost::asio::io_context::executor_type> strand_; - boost::beast::multi_buffer buffer_; + net::strand< + net::io_context::executor_type> strand_; + beast::multi_buffer buffer_; public: // Take ownership of the socket @@ -75,7 +78,7 @@ public: #include void loop( - boost::system::error_code ec, + beast::error_code ec, std::size_t bytes_transferred) { boost::ignore_unused(bytes_transferred); @@ -85,7 +88,7 @@ public: // Perform the SSL handshake yield ws_.next_layer().async_handshake( ssl::stream_base::server, - boost::asio::bind_executor( + net::bind_executor( strand_, std::bind( &session::loop, @@ -97,7 +100,7 @@ public: // Accept the websocket handshake yield ws_.async_accept( - boost::asio::bind_executor( + net::bind_executor( strand_, std::bind( &session::loop, @@ -112,7 +115,7 @@ public: // Read a message into our buffer yield ws_.async_read( buffer_, - boost::asio::bind_executor( + net::bind_executor( strand_, std::bind( &session::loop, @@ -131,7 +134,7 @@ public: ws_.text(ws_.got_text()); yield ws_.async_write( buffer_.data(), - boost::asio::bind_executor( + net::bind_executor( strand_, std::bind( &session::loop, @@ -153,7 +156,7 @@ public: // Accepts incoming connections and launches the sessions class listener - : public boost::asio::coroutine + : public net::coroutine , public std::enable_shared_from_this { ssl::context& ctx_; @@ -162,14 +165,14 @@ class listener public: listener( - boost::asio::io_context& ioc, + net::io_context& ioc, ssl::context& ctx, tcp::endpoint endpoint) : ctx_(ctx) , acceptor_(ioc) , socket_(ioc) { - boost::system::error_code ec; + beast::error_code ec; // Open the acceptor acceptor_.open(endpoint.protocol(), ec); @@ -180,7 +183,7 @@ public: } // Allow address reuse - acceptor_.set_option(boost::asio::socket_base::reuse_address(true), ec); + acceptor_.set_option(net::socket_base::reuse_address(true), ec); if(ec) { fail(ec, "set_option"); @@ -197,7 +200,7 @@ public: // Start listening for connections acceptor_.listen( - boost::asio::socket_base::max_listen_connections, ec); + net::socket_base::max_listen_connections, ec); if(ec) { fail(ec, "listen"); @@ -216,7 +219,7 @@ public: #include void - loop(boost::system::error_code ec = {}) + loop(beast::error_code ec = {}) { reenter(*this) { @@ -256,12 +259,12 @@ int main(int argc, char* argv[]) " websocket-server-async-ssl 0.0.0.0 8080 1\n"; return EXIT_FAILURE; } - auto const address = boost::asio::ip::make_address(argv[1]); + auto const address = net::ip::make_address(argv[1]); auto const port = static_cast(std::atoi(argv[2])); auto const threads = std::max(1, std::atoi(argv[3])); // The io_context is required for all I/O - boost::asio::io_context ioc{threads}; + net::io_context ioc{threads}; // The SSL context is required, and holds certificates ssl::context ctx{ssl::context::sslv23}; diff --git a/example/websocket/server/stackless/websocket_server_stackless.cpp b/example/websocket/server/stackless/websocket_server_stackless.cpp index 3ce83654..a2b0b564 100644 --- a/example/websocket/server/stackless/websocket_server_stackless.cpp +++ b/example/websocket/server/stackless/websocket_server_stackless.cpp @@ -28,27 +28,30 @@ #include #include -using tcp = boost::asio::ip::tcp; // from -namespace websocket = boost::beast::websocket; // from +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +using tcp = boost::asio::ip::tcp; // from //------------------------------------------------------------------------------ // Report a failure void -fail(boost::system::error_code ec, char const* what) +fail(beast::error_code ec, char const* what) { std::cerr << what << ": " << ec.message() << "\n"; } // Echoes back all received WebSocket messages class session - : public boost::asio::coroutine + : public net::coroutine , public std::enable_shared_from_this { websocket::stream ws_; - boost::asio::strand< - boost::asio::io_context::executor_type> strand_; - boost::beast::multi_buffer buffer_; + net::strand< + net::io_context::executor_type> strand_; + beast::multi_buffer buffer_; public: // Take ownership of the socket @@ -69,7 +72,7 @@ public: #include void loop( - boost::system::error_code ec, + beast::error_code ec, std::size_t bytes_transferred) { boost::ignore_unused(bytes_transferred); @@ -77,7 +80,7 @@ public: { // Accept the websocket handshake yield ws_.async_accept( - boost::asio::bind_executor( + net::bind_executor( strand_, std::bind( &session::loop, @@ -92,7 +95,7 @@ public: // Read a message into our buffer yield ws_.async_read( buffer_, - boost::asio::bind_executor( + net::bind_executor( strand_, std::bind( &session::loop, @@ -111,7 +114,7 @@ public: ws_.text(ws_.got_text()); yield ws_.async_write( buffer_.data(), - boost::asio::bind_executor( + net::bind_executor( strand_, std::bind( &session::loop, @@ -133,7 +136,7 @@ public: // Accepts incoming connections and launches the sessions class listener - : public boost::asio::coroutine + : public net::coroutine , public std::enable_shared_from_this { tcp::acceptor acceptor_; @@ -141,12 +144,12 @@ class listener public: listener( - boost::asio::io_context& ioc, + net::io_context& ioc, tcp::endpoint endpoint) : acceptor_(ioc) , socket_(ioc) { - boost::system::error_code ec; + beast::error_code ec; // Open the acceptor acceptor_.open(endpoint.protocol(), ec); @@ -157,7 +160,7 @@ public: } // Allow address reuse - acceptor_.set_option(boost::asio::socket_base::reuse_address(true), ec); + acceptor_.set_option(net::socket_base::reuse_address(true), ec); if(ec) { fail(ec, "set_option"); @@ -174,7 +177,7 @@ public: // Start listening for connections acceptor_.listen( - boost::asio::socket_base::max_listen_connections, ec); + net::socket_base::max_listen_connections, ec); if(ec) { fail(ec, "listen"); @@ -193,7 +196,7 @@ public: #include void - loop(boost::system::error_code ec = {}) + loop(beast::error_code ec = {}) { reenter(*this) { @@ -233,12 +236,12 @@ int main(int argc, char* argv[]) " websocket-server-stackless 0.0.0.0 8080 1\n"; return EXIT_FAILURE; } - auto const address = boost::asio::ip::make_address(argv[1]); + auto const address = net::ip::make_address(argv[1]); auto const port = static_cast(std::atoi(argv[2])); auto const threads = std::max(1, std::atoi(argv[3])); // The io_context is required for all I/O - boost::asio::io_context ioc{threads}; + net::io_context ioc{threads}; // Create and launch a listening port std::make_shared(ioc, tcp::endpoint{address, port})->run(); diff --git a/example/websocket/server/sync-ssl/websocket_server_sync_ssl.cpp b/example/websocket/server/sync-ssl/websocket_server_sync_ssl.cpp index 1e3f7332..789e8b4a 100644 --- a/example/websocket/server/sync-ssl/websocket_server_sync_ssl.cpp +++ b/example/websocket/server/sync-ssl/websocket_server_sync_ssl.cpp @@ -26,9 +26,12 @@ #include #include -using tcp = boost::asio::ip::tcp; // from -namespace ssl = boost::asio::ssl; // from -namespace websocket = boost::beast::websocket; // from +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +namespace ssl = boost::asio::ssl; // from +using tcp = boost::asio::ip::tcp; // from //------------------------------------------------------------------------------ @@ -50,7 +53,7 @@ do_session(tcp::socket& socket, ssl::context& ctx) for(;;) { // This buffer will hold the incoming message - boost::beast::multi_buffer buffer; + beast::multi_buffer buffer; // Read a message ws.read(buffer); @@ -60,7 +63,7 @@ do_session(tcp::socket& socket, ssl::context& ctx) ws.write(buffer.data()); } } - catch(boost::system::system_error const& se) + catch(beast::system_error const& se) { // This indicates that the session was closed if(se.code() != websocket::error::closed) @@ -87,11 +90,11 @@ int main(int argc, char* argv[]) " websocket-server-sync-ssl 0.0.0.0 8080\n"; return EXIT_FAILURE; } - auto const address = boost::asio::ip::make_address(argv[1]); + auto const address = net::ip::make_address(argv[1]); auto const port = static_cast(std::atoi(argv[2])); // The io_context is required for all I/O - boost::asio::io_context ioc{1}; + net::io_context ioc{1}; // The SSL context is required, and holds certificates ssl::context ctx{ssl::context::sslv23}; diff --git a/example/websocket/server/sync/websocket_server_sync.cpp b/example/websocket/server/sync/websocket_server_sync.cpp index 7a4878cf..0d50f438 100644 --- a/example/websocket/server/sync/websocket_server_sync.cpp +++ b/example/websocket/server/sync/websocket_server_sync.cpp @@ -22,8 +22,11 @@ #include #include -using tcp = boost::asio::ip::tcp; // from -namespace websocket = boost::beast::websocket; // from +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +using tcp = boost::asio::ip::tcp; // from //------------------------------------------------------------------------------ @@ -42,7 +45,7 @@ do_session(tcp::socket& socket) for(;;) { // This buffer will hold the incoming message - boost::beast::multi_buffer buffer; + beast::multi_buffer buffer; // Read a message ws.read(buffer); @@ -52,7 +55,7 @@ do_session(tcp::socket& socket) ws.write(buffer.data()); } } - catch(boost::system::system_error const& se) + catch(beast::system_error const& se) { // This indicates that the session was closed if(se.code() != websocket::error::closed) @@ -79,11 +82,11 @@ int main(int argc, char* argv[]) " websocket-server-sync 0.0.0.0 8080\n"; return EXIT_FAILURE; } - auto const address = boost::asio::ip::make_address(argv[1]); + auto const address = net::ip::make_address(argv[1]); auto const port = static_cast(std::atoi(argv[2])); // The io_context is required for all I/O - boost::asio::io_context ioc{1}; + net::io_context ioc{1}; // The acceptor receives incoming connections tcp::acceptor acceptor{ioc, {address, port}}; diff --git a/include/boost/beast/_experimental/core/detail/flat_stream.hpp b/include/boost/beast/_experimental/core/detail/flat_stream.hpp index 3a56897b..a253b5ef 100644 --- a/include/boost/beast/_experimental/core/detail/flat_stream.hpp +++ b/include/boost/beast/_experimental/core/detail/flat_stream.hpp @@ -32,11 +32,11 @@ public: coalesce(BufferSequence const& buffers, std::size_t limit) { std::pair result{0, false}; - auto first = boost::asio::buffer_sequence_begin(buffers); - auto last = boost::asio::buffer_sequence_end(buffers); + auto first = net::buffer_sequence_begin(buffers); + auto last = net::buffer_sequence_end(buffers); if(first != last) { - result.first = boost::asio::buffer_size(*first); + result.first = net::buffer_size(*first); if(result.first < limit) { auto it = first; @@ -44,7 +44,7 @@ public: while(++it != last) { auto const n = - boost::asio::buffer_size(*it); + net::buffer_size(*it); if(result.first + n > limit) break; result.first += n; diff --git a/include/boost/beast/_experimental/core/detail/impl/timeout_service.hpp b/include/boost/beast/_experimental/core/detail/impl/timeout_service.hpp index 8bc90b35..4cbbc821 100644 --- a/include/boost/beast/_experimental/core/detail/impl/timeout_service.hpp +++ b/include/boost/beast/_experimental/core/detail/impl/timeout_service.hpp @@ -15,7 +15,7 @@ namespace beast { namespace detail { timeout_service:: -timeout_service(boost::asio::io_context& ctx) +timeout_service(net::io_context& ctx) : service_base(ctx) , thunks_(1) // element [0] reserved for "null" , timer_(ctx) @@ -272,7 +272,7 @@ void timeout_service:: on_timer(error_code ec) { - if(ec == boost::asio::error::operation_aborted) + if(ec == net::error::operation_aborted) { BOOST_ASSERT(fresh_->empty()); BOOST_ASSERT(stale_->empty()); diff --git a/include/boost/beast/_experimental/core/detail/service_base.hpp b/include/boost/beast/_experimental/core/detail/service_base.hpp index 278db3f7..b936a0bc 100644 --- a/include/boost/beast/_experimental/core/detail/service_base.hpp +++ b/include/boost/beast/_experimental/core/detail/service_base.hpp @@ -17,23 +17,23 @@ namespace beast { namespace detail { template -class service_id : public boost::asio::execution_context::id +class service_id : public net::execution_context::id { }; template class service_base - : public boost::asio::execution_context::service + : public net::execution_context::service { protected: - boost::asio::execution_context& ctx_; + net::execution_context& ctx_; public: static service_id id; explicit - service_base(boost::asio::execution_context& ctx) - : boost::asio::execution_context::service(ctx) + service_base(net::execution_context& ctx) + : net::execution_context::service(ctx) , ctx_(ctx) { } diff --git a/include/boost/beast/_experimental/core/detail/timeout_service.hpp b/include/boost/beast/_experimental/core/detail/timeout_service.hpp index fbe72ad3..7637fb79 100644 --- a/include/boost/beast/_experimental/core/detail/timeout_service.hpp +++ b/include/boost/beast/_experimental/core/detail/timeout_service.hpp @@ -45,7 +45,7 @@ class timeout_service void operator()() { - boost::asio::post(ex, + net::post(ex, beast::bind_front_handler( std::move(*this), 0)); } @@ -64,7 +64,7 @@ public: // VFALCO Should be execution_context BOOST_BEAST_DECL explicit - timeout_service(boost::asio::io_context& ctx); + timeout_service(net::io_context& ctx); BOOST_BEAST_DECL timeout_handle @@ -119,7 +119,7 @@ private: thunk::list_type* stale_ = &list_[1]; std::deque thunks_; std::size_t free_thunk_ = 0; - boost::asio::steady_timer timer_; + net::steady_timer timer_; std::chrono::seconds interval_{30ul}; long pending_ = 0; }; diff --git a/include/boost/beast/_experimental/core/flat_stream.hpp b/include/boost/beast/_experimental/core/flat_stream.hpp index 9dfb1400..d74426bd 100644 --- a/include/boost/beast/_experimental/core/flat_stream.hpp +++ b/include/boost/beast/_experimental/core/flat_stream.hpp @@ -26,7 +26,7 @@ namespace beast { This wrapper flattens writes for buffer sequences having length greater than 1 and total size below a predefined amount, using a dynamic memory allocation. It is primarily designed to overcome - a performance limitation of the current version of `boost::asio::ssl::stream`, + a performance limitation of the current version of `net::ssl::stream`, which does not use OpenSSL's scatter/gather interface for its low-level read some and write some operations. @@ -49,11 +49,11 @@ namespace beast { operate on synchronous or asynchronous read or write streams, examples include: - @li `boost::asio::read`, `boost::asio::async_read` + @li `net::read`, `net::async_read` - @li `boost::asio::write`, `boost::asio::async_write` + @li `net::write`, `net::async_write` - @li `boost::asio::read_until`, `boost::asio::async_read_until` + @li `net::read_until`, `net::async_read_until` The stream may also be used as a template parameter in other stream wrappers, such as for websocket: @@ -66,7 +66,7 @@ namespace beast { operations, the type must support the @b SyncStream concept. For asynchronous operations, the type must support the @b AsyncStream concept. This type will usually be some variation of - `boost::asio::ssl::stream`. + `net::ssl::stream`. @par Concepts @b AsyncStream @@ -209,7 +209,7 @@ public: @throws boost::system::system_error Thrown on failure. @note The `read_some` operation may not read all of the requested number of - bytes. Consider using the function `boost::asio::read` if you need to ensure + bytes. Consider using the function `net::read` if you need to ensure that the requested amount of data is read before the blocking operation completes. */ @@ -230,7 +230,7 @@ public: @returns The number of bytes read. @note The `read_some` operation may not read all of the requested number of - bytes. Consider using the function `boost::asio::read` if you need to ensure + bytes. Consider using the function `net::read` if you need to ensure that the requested amount of data is read before the blocking operation completes. */ @@ -259,7 +259,7 @@ public: ); @endcode @note The `read_some` operation may not read all of the requested number of - bytes. Consider using the function `boost::asio::async_read` if you need + bytes. Consider using the function `net::async_read` if you need to ensure that the requested amount of data is read before the asynchronous operation completes. */ @@ -285,7 +285,7 @@ public: @throws boost::system::system_error Thrown on failure. @note The `write_some` operation may not transmit all of the data to the - peer. Consider using the function `boost::asio::write` if you need to + peer. Consider using the function `net::write` if you need to ensure that all data is written before the blocking operation completes. */ template @@ -305,7 +305,7 @@ public: @returns The number of bytes written. @note The `write_some` operation may not transmit all of the data to the - peer. Consider using the function `boost::asio::write` if you need to + peer. Consider using the function `net::write` if you need to ensure that all data is written before the blocking operation completes. */ template @@ -333,7 +333,7 @@ public: ); @endcode @note The `async_write_some` operation may not transmit all of the data to - the peer. Consider using the function `boost::asio::async_write` if you need + the peer. Consider using the function `net::async_write` if you need to ensure that all data is written before the asynchronous operation completes. */ template< diff --git a/include/boost/beast/_experimental/core/impl/flat_stream.ipp b/include/boost/beast/_experimental/core/impl/flat_stream.ipp index a94622f7..b8b5320b 100644 --- a/include/boost/beast/_experimental/core/impl/flat_stream.ipp +++ b/include/boost/beast/_experimental/core/impl/flat_stream.ipp @@ -25,14 +25,14 @@ namespace beast { template template class flat_stream::write_op - : public boost::asio::coroutine + : public net::coroutine { using alloc_type = typename #if defined(BOOST_NO_CXX11_ALLOCATOR) - boost::asio::associated_allocator_t::template + net::associated_allocator_t::template rebind::other; #else - std::allocator_traits> + std::allocator_traits> ::template rebind_alloc; #endif @@ -68,27 +68,27 @@ public: : s_(s) , b_(b) , p_(nullptr, deleter{ - (boost::asio::get_associated_allocator)(h)}) + (net::get_associated_allocator)(h)}) , h_(std::forward(h)) { } using allocator_type = - boost::asio::associated_allocator_t; + net::associated_allocator_t; allocator_type get_allocator() const noexcept { - return (boost::asio::get_associated_allocator)(h_); + return (net::get_associated_allocator)(h_); } - using executor_type = boost::asio::associated_executor_t< + using executor_type = net::associated_executor_t< Handler, decltype(std::declval().get_executor())>; executor_type get_executor() const noexcept { - return (boost::asio::get_associated_executor)( + return (net::get_associated_executor)( h_, s_.get_executor()); } @@ -100,7 +100,7 @@ public: friend bool asio_handler_is_continuation(write_op* op) { - using boost::asio::asio_handler_is_continuation; + using net::asio_handler_is_continuation; return asio_handler_is_continuation( std::addressof(op->h_)); } @@ -109,7 +109,7 @@ public: friend void asio_handler_invoke(Function&& f, write_op* op) { - using boost::asio::asio_handler_invoke; + using net::asio_handler_invoke; asio_handler_invoke(f, std::addressof(op->h_)); } }; @@ -133,12 +133,12 @@ operator()( p_.get_deleter().size = result.first; p_.reset(p_.get_deleter().alloc.allocate( p_.get_deleter().size)); - boost::asio::buffer_copy( - boost::asio::buffer( + net::buffer_copy( + net::buffer( p_.get(), p_.get_deleter().size), b_, result.first); s_.stream_.async_write_some( - boost::asio::buffer( + net::buffer( p_.get(), p_.get_deleter().size), std::move(*this)); } @@ -172,7 +172,7 @@ read_some(MutableBufferSequence const& buffers) { static_assert(boost::beast::is_sync_read_stream::value, "SyncReadStream requirements not met"); - static_assert(boost::asio::is_mutable_buffer_sequence< + static_assert(net::is_mutable_buffer_sequence< MutableBufferSequence>::value, "MutableBufferSequence requirements not met"); error_code ec; @@ -204,7 +204,7 @@ async_read_some( { static_assert(boost::beast::is_async_read_stream::value, "AsyncReadStream requirements not met"); - static_assert(boost::asio::is_mutable_buffer_sequence< + static_assert(net::is_mutable_buffer_sequence< MutableBufferSequence >::value, "MutableBufferSequence requirements not met"); return stream_.async_read_some( @@ -219,15 +219,15 @@ write_some(ConstBufferSequence const& buffers) { static_assert(boost::beast::is_sync_write_stream::value, "SyncWriteStream requirements not met"); - static_assert(boost::asio::is_const_buffer_sequence< + static_assert(net::is_const_buffer_sequence< ConstBufferSequence>::value, "ConstBufferSequence requirements not met"); auto const result = coalesce(buffers, coalesce_limit); if(result.second) { std::unique_ptr p{new char[result.first]}; - auto const b = boost::asio::buffer(p.get(), result.first); - boost::asio::buffer_copy(b, buffers); + auto const b = net::buffer(p.get(), result.first); + net::buffer_copy(b, buffers); return stream_.write_some(b); } return stream_.write_some( @@ -242,15 +242,15 @@ write_some(ConstBufferSequence const& buffers, error_code& ec) { static_assert(boost::beast::is_sync_write_stream::value, "SyncWriteStream requirements not met"); - static_assert(boost::asio::is_const_buffer_sequence< + static_assert(net::is_const_buffer_sequence< ConstBufferSequence>::value, "ConstBufferSequence requirements not met"); auto const result = coalesce(buffers, coalesce_limit); if(result.second) { std::unique_ptr p{new char[result.first]}; - auto const b = boost::asio::buffer(p.get(), result.first); - boost::asio::buffer_copy(b, buffers); + auto const b = net::buffer(p.get(), result.first); + net::buffer_copy(b, buffers); return stream_.write_some(b, ec); } return stream_.write_some( @@ -270,7 +270,7 @@ async_write_some( { static_assert(boost::beast::is_async_write_stream::value, "AsyncWriteStream requirements not met"); - static_assert(boost::asio::is_const_buffer_sequence< + static_assert(net::is_const_buffer_sequence< ConstBufferSequence>::value, "ConstBufferSequence requirements not met"); BOOST_BEAST_HANDLER_INIT( diff --git a/include/boost/beast/_experimental/core/impl/timeout_service.hpp b/include/boost/beast/_experimental/core/impl/timeout_service.hpp index 79338b49..61aeda06 100644 --- a/include/boost/beast/_experimental/core/impl/timeout_service.hpp +++ b/include/boost/beast/_experimental/core/impl/timeout_service.hpp @@ -18,9 +18,9 @@ namespace boost { namespace beast { timeout_handle:: -timeout_handle(boost::asio::io_context& ioc) +timeout_handle(net::io_context& ioc) : timeout_handle( - boost::asio::use_service< + net::use_service< detail::timeout_service>( ioc).make_handle()) { @@ -50,10 +50,10 @@ set_callback( void set_timeout_service_options( - boost::asio::io_context& ioc, + net::io_context& ioc, std::chrono::seconds interval) { - boost::asio::use_service< + net::use_service< detail::timeout_service>( ioc).set_option(interval); } diff --git a/include/boost/beast/_experimental/core/impl/timeout_socket.hpp b/include/boost/beast/_experimental/core/impl/timeout_socket.hpp index 1c05b133..1e25c8d2 100644 --- a/include/boost/beast/_experimental/core/impl/timeout_socket.hpp +++ b/include/boost/beast/_experimental/core/impl/timeout_socket.hpp @@ -61,30 +61,30 @@ public: } using allocator_type = - boost::asio::associated_allocator_t; + net::associated_allocator_t; allocator_type get_allocator() const noexcept { - return boost::asio::get_associated_allocator(h_); + return net::get_associated_allocator(h_); } using executor_type = - boost::asio::associated_executor_t&>().get_executor())>; executor_type get_executor() const noexcept { - return boost::asio::get_associated_executor( + return net::get_associated_executor( h_, s_.get_executor()); } friend bool asio_handler_is_continuation(async_op* op) { - using boost::asio::asio_handler_is_continuation; + using net::asio_handler_is_continuation; return asio_handler_is_continuation( std::addressof(op->h_)); } @@ -93,7 +93,7 @@ public: friend void asio_handler_invoke(Function&& f, async_op* op) { - using boost::asio::asio_handler_invoke; + using net::asio_handler_invoke; asio_handler_invoke(f, std::addressof(op->h_)); } @@ -115,8 +115,8 @@ private: Handler h_; basic_timeout_socket& s_; timeout_work_guard work_; - boost::asio::executor_work_guard wg0_; - boost::asio::executor_work_guard wg1_; + net::executor_work_guard wg0_; + net::executor_work_guard wg1_; detail::saved_handler& saved_; }; @@ -177,7 +177,7 @@ async_read_some( MutableBufferSequence const& buffers, ReadHandler&& handler) { - static_assert(boost::asio::is_mutable_buffer_sequence< + static_assert(net::is_mutable_buffer_sequence< MutableBufferSequence>::value, "MutableBufferSequence requirements not met"); BOOST_BEAST_HANDLER_INIT( @@ -198,7 +198,7 @@ async_write_some( ConstBufferSequence const& buffers, WriteHandler&& handler) { - static_assert(boost::asio::is_const_buffer_sequence< + static_assert(net::is_const_buffer_sequence< ConstBufferSequence>::value, "ConstBufferSequence requirements not met"); BOOST_BEAST_HANDLER_INIT( @@ -235,36 +235,36 @@ public: , wg0_(s_.get_executor()) , wg1_(get_executor()) { - boost::asio::async_connect( + net::async_connect( s_.next_layer(), eps, cond, std::move(*this)); } using allocator_type = - boost::asio::associated_allocator_t; + net::associated_allocator_t; allocator_type get_allocator() const noexcept { - return boost::asio::get_associated_allocator(h_); + return net::get_associated_allocator(h_); } using executor_type = - boost::asio::associated_executor_t&>().get_executor())>; executor_type get_executor() const noexcept { - return boost::asio::get_associated_executor( + return net::get_associated_executor( h_, s_.get_executor()); } friend bool asio_handler_is_continuation(connect_op* op) { - using boost::asio::asio_handler_is_continuation; + using net::asio_handler_is_continuation; return asio_handler_is_continuation( std::addressof(op->h_)); } @@ -273,7 +273,7 @@ public: friend void asio_handler_invoke(Function&& f, connect_op* op) { - using boost::asio::asio_handler_invoke; + using net::asio_handler_invoke; asio_handler_invoke(f, std::addressof(op->h_)); } @@ -296,8 +296,8 @@ private: Handler h_; timeout_work_guard work_; basic_timeout_socket& s_; - boost::asio::executor_work_guard wg0_; - boost::asio::executor_work_guard wg1_; + net::executor_work_guard wg0_; + net::executor_work_guard wg1_; }; struct any_endpoint diff --git a/include/boost/beast/_experimental/core/ssl_stream.hpp b/include/boost/beast/_experimental/core/ssl_stream.hpp index f3d8f4a5..fe2683e2 100644 --- a/include/boost/beast/_experimental/core/ssl_stream.hpp +++ b/include/boost/beast/_experimental/core/ssl_stream.hpp @@ -37,14 +37,14 @@ namespace beast { strand. @par Example - To use this template with a `boost::asio::ip::tcp::socket`, you would write: + To use this template with a `net::ip::tcp::socket`, you would write: @code - boost::asio::io_context ioc; - boost::asio::ssl::context ctx{boost::asio::ssl::context::sslv23}; - boost::beast::ssl_stream sock{ioc, ctx}; + net::io_context ioc; + net::ssl::context ctx{net::ssl::context::sslv23}; + boost::beast::ssl_stream sock{ioc, ctx}; @endcode - In addition to providing an interface identical to `boost::asio::ssl::stream`, + In addition to providing an interface identical to `net::ssl::stream`, the wrapper has the following additional properties: @li Satisfies @b MoveConstructible @@ -54,7 +54,7 @@ namespace beast { @li Constructible from a moved socket. @li Uses @ref flat_stream internally, as a performance work-around for a - limitation of `boost::asio::ssl::stream` when writing buffer sequences + limitation of `net::ssl::stream` when writing buffer sequences having length greater than one. @par Concepts: @@ -66,9 +66,9 @@ namespace beast { */ template class ssl_stream - : public boost::asio::ssl::stream_base + : public net::ssl::stream_base { - using ssl_stream_type = boost::asio::ssl::stream; + using ssl_stream_type = net::ssl::stream; using stream_type = boost::beast::flat_stream; std::unique_ptr p_; @@ -102,7 +102,7 @@ public: template ssl_stream( Arg&& arg, - boost::asio::ssl::context& ctx) + net::ssl::context& ctx) : p_(new stream_type{ std::forward(arg), ctx}) { @@ -132,7 +132,7 @@ public: suitable for passing to functions such as @c SSL_get_verify_result and @c SSL_get_peer_certificate: @code - boost::beast::ssl_stream ss{ioc, ctx}; + boost::beast::ssl_stream ss{ioc, ctx}; // ... establish connection and perform handshake ... @@ -225,7 +225,7 @@ public: @note Calls @c SSL_set_verify. */ void - set_verify_mode(boost::asio::ssl::verify_mode v) + set_verify_mode(net::ssl::verify_mode v) { p_->next_layer().set_verify_mode(v); } @@ -243,7 +243,7 @@ public: @note Calls @c SSL_set_verify. */ void - set_verify_mode(boost::asio::ssl::verify_mode v, + set_verify_mode(net::ssl::verify_mode v, boost::system::error_code& ec) { p_->next_layer().set_verify_mode(v, ec); @@ -320,7 +320,7 @@ public: The function signature of the handler must be: @code bool verify_callback( bool preverified, // True if the certificate passed pre-verification. - boost::asio::verify_context& ctx // The peer certificate and other context. + net::verify_context& ctx // The peer certificate and other context. ); @endcode The return value of the callback is true if the certificate has passed verification, false otherwise. @@ -527,7 +527,7 @@ public: @throws boost::system::system_error Thrown on failure. @note The `write_some` operation may not transmit all of the data to the - peer. Consider using the `boost::asio::write` function if you need to + peer. Consider using the `net::write` function if you need to ensure that all data is written before the blocking operation completes. */ template @@ -550,7 +550,7 @@ public: @returns The number of bytes written. Returns 0 if an error occurred. @note The `write_some` operation may not transmit all of the data to the - peer. Consider using the `boost::asio::write` function if you need to + peer. Consider using the `net::write` function if you need to ensure that all data is written before the blocking operation completes. */ template @@ -580,7 +580,7 @@ public: ); @endcode @note The `async_write_some` operation may not transmit all of the data to - the peer. Consider using the `boost::asio::async_write` function if you + the peer. Consider using the `net::async_write` function if you need to ensure that all data is written before the asynchronous operation completes. */ @@ -607,7 +607,7 @@ public: @throws boost::system::system_error Thrown on failure. @note The `read_some` operation may not read all of the requested number of - bytes. Consider using the `boost::asio::read` function if you need to ensure + bytes. Consider using the `net::read` function if you need to ensure that the requested amount of data is read before the blocking operation completes. */ @@ -631,7 +631,7 @@ public: @returns The number of bytes read. Returns 0 if an error occurred. @note The `read_some` operation may not read all of the requested number of - bytes. Consider using the `boost::asio::read` function if you need to ensure + bytes. Consider using the `net::read` function if you need to ensure that the requested amount of data is read before the blocking operation completes. */ @@ -662,7 +662,7 @@ public: ); @endcode @note The `async_read_some` operation may not read all of the requested - number of bytes. Consider using the `boost::asio::async_read` function + number of bytes. Consider using the `net::async_read` function if you need to ensure that the requested amount of data is read before the asynchronous operation completes. */ diff --git a/include/boost/beast/_experimental/core/timeout_service.hpp b/include/boost/beast/_experimental/core/timeout_service.hpp index f44daf96..894e6a5c 100644 --- a/include/boost/beast/_experimental/core/timeout_service.hpp +++ b/include/boost/beast/_experimental/core/timeout_service.hpp @@ -67,7 +67,7 @@ public: // VFALCO should be execution_context BOOST_BEAST_DECL explicit - timeout_handle(boost::asio::io_context& ioc); + timeout_handle(net::io_context& ioc); BOOST_BEAST_DECL void @@ -126,7 +126,7 @@ public: BOOST_BEAST_DECL void set_timeout_service_options( - boost::asio::io_context& ctx, // VFALCO should be execution_context + net::io_context& ctx, // VFALCO should be execution_context std::chrono::seconds interval); } // beast diff --git a/include/boost/beast/_experimental/core/timeout_socket.hpp b/include/boost/beast/_experimental/core/timeout_socket.hpp index 5fd69dc7..e965b3dc 100644 --- a/include/boost/beast/_experimental/core/timeout_socket.hpp +++ b/include/boost/beast/_experimental/core/timeout_socket.hpp @@ -46,7 +46,7 @@ class connect_op; */ template< class Protocol, - class Executor = boost::asio::executor + class Executor = net::executor > class basic_timeout_socket { @@ -57,14 +57,14 @@ class basic_timeout_socket timeout_handle rd_timer_; timeout_handle wr_timer_; timeout_handle cn_timer_; - boost::asio::basic_stream_socket sock_; + net::basic_stream_socket sock_; detail::saved_handler rd_op_; detail::saved_handler wr_op_; detail::saved_handler cn_op_; public: /// The type of the next layer. - using next_layer_type = boost::asio::basic_stream_socket; + using next_layer_type = net::basic_stream_socket; /// The type of the lowest layer. using lowest_layer_type = get_lowest_layer; @@ -93,7 +93,7 @@ public: , class = typename std::enable_if< std::is_convertible< ExecutionContext&, - boost::asio::execution_context&>::value && + net::execution_context&>::value && std::is_constructible< executor_type, typename ExecutionContext::executor_type>::value @@ -196,7 +196,7 @@ public: Regardless of whether the asynchronous operation completes immediately or not, the handler will not be invoked from within this function. Invocation of the handler will be performed in a manner equivalent to using - boost::asio::io_context::post(). + net::io_context::post(). */ template BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler, @@ -225,7 +225,7 @@ public: Regardless of whether the asynchronous operation completes immediately or not, the handler will not be invoked from within this function. Invocation of the handler will be performed in a manner equivalent to using - boost::asio::io_context::post(). + net::io_context::post(). */ template BOOST_ASIO_INITFN_RESULT_TYPE(WriteHandler, @@ -239,8 +239,8 @@ public: /// A TCP/IP socket wrapper which has a built-in asynchronous timeout using timeout_socket = basic_timeout_socket< - boost::asio::ip::tcp, - boost::asio::io_context::executor_type>; + net::ip::tcp, + net::io_context::executor_type>; /** @defgroup async_connect boost::beast::async_connect @@ -267,7 +267,7 @@ using timeout_socket = basic_timeout_socket< @code void handler( // Result of operation. if the sequence is empty, set to - // boost::asio::error::not_found. Otherwise, contains the + // net::error::not_found. Otherwise, contains the // error from the last connection attempt. error_code const& error, @@ -280,13 +280,13 @@ using timeout_socket = basic_timeout_socket< Regardless of whether the asynchronous operation completes immediately or not, the handler will not be invoked from within this function. Invocation of the handler will be performed in a manner equivalent to using - `boost::asio::io_context::post()`. + `net::io_context::post()`. @par Example @code - boost::asio::tcp::resolver r(ioc); - boost::asio::tcp::resolver::query q("host", "service"); + net::tcp::resolver r(ioc); + net::tcp::resolver::query q("host", "service"); timeout_socket s(ioc.get_executor()); // ... @@ -321,7 +321,7 @@ template< class RangeConnectHandler #if ! BOOST_BEAST_DOXYGEN ,class = typename std::enable_if< - boost::asio::is_endpoint_sequence< + net::is_endpoint_sequence< EndpointSequence>::value>::type #endif > @@ -365,7 +365,7 @@ async_connect( @code void handler( // Result of operation. if the sequence is empty, set to - // boost::asio::error::not_found. Otherwise, contains the + // net::error::not_found. Otherwise, contains the // error from the last connection attempt. error_code const& error, @@ -378,7 +378,7 @@ async_connect( Regardless of whether the asynchronous operation completes immediately or not, the handler will not be invoked from within this function. Invocation of the handler will be performed in a manner equivalent to using - `boost::asio::io_context::post()`. + `net::io_context::post()`. @par Example @@ -390,7 +390,7 @@ async_connect( { bool operator()( boost::system::error_code const& ec, - boost::asio::ip::tcp::endpoint const& next) + net::ip::tcp::endpoint const& next) { if (ec) std::cout << "Error: " << ec.message() << std::endl; std::cout << "Trying: " << next << std::endl; @@ -403,8 +403,8 @@ async_connect( function as follows: @code - boost::asio::tcp::resolver r(ioc); - boost::asio::tcp::resolver::query q("host", "service"); + net::tcp::resolver r(ioc); + net::tcp::resolver::query q("host", "service"); timeout_socket s(ioc.get_executor()); // ... @@ -440,7 +440,7 @@ template< class RangeConnectHandler #if ! BOOST_BEAST_DOXYGEN ,class = typename std::enable_if< - boost::asio::is_endpoint_sequence< + net::is_endpoint_sequence< EndpointSequence>::value>::type #endif > @@ -472,7 +472,7 @@ async_connect( @code void handler( // Result of operation. if the sequence is empty, set to - // boost::asio::error::not_found. Otherwise, contains the + // net::error::not_found. Otherwise, contains the // error from the last connection attempt. error_code const& error, @@ -485,7 +485,7 @@ async_connect( Regardless of whether the asynchronous operation completes immediately or not, the handler will not be invoked from within this function. Invocation of the handler will be performed in a manner equivalent to using - `boost::asio::io_context::post()`. + `net::io_context::post()`. @par Example @@ -511,7 +511,7 @@ template< class IteratorConnectHandler #if ! BOOST_BEAST_DOXYGEN ,class = typename std::enable_if< - ! boost::asio::is_endpoint_sequence< + ! net::is_endpoint_sequence< Iterator>::value>::type #endif > @@ -551,7 +551,7 @@ async_connect( @code void handler( // Result of operation. if the sequence is empty, set to - // boost::asio::error::not_found. Otherwise, contains the + // net::error::not_found. Otherwise, contains the // error from the last connection attempt. error_code const& error, @@ -564,7 +564,7 @@ async_connect( Regardless of whether the asynchronous operation completes immediately or not, the handler will not be invoked from within this function. Invocation of the handler will be performed in a manner equivalent to using - `boost::asio::io_context::post()`. + `net::io_context::post()`. @par Example @@ -576,7 +576,7 @@ async_connect( { bool operator()( boost::system::error_code const& ec, - boost::asio::ip::tcp::endpoint const& next) + net::ip::tcp::endpoint const& next) { if (ec) std::cout << "Error: " << ec.message() << std::endl; std::cout << "Trying: " << next << std::endl; @@ -610,7 +610,7 @@ template< class IteratorConnectHandler #if ! BOOST_BEAST_DOXYGEN ,class = typename std::enable_if< - ! boost::asio::is_endpoint_sequence< + ! net::is_endpoint_sequence< Iterator>::value>::type #endif > diff --git a/include/boost/beast/_experimental/http/icy_stream.hpp b/include/boost/beast/_experimental/http/icy_stream.hpp index 542ae04a..87ed0bbc 100644 --- a/include/boost/beast/_experimental/http/icy_stream.hpp +++ b/include/boost/beast/_experimental/http/icy_stream.hpp @@ -76,7 +76,7 @@ class icy_stream char buf_[8]; static - boost::asio::const_buffer + net::const_buffer version() { return {"HTTP/1.1", 8}; @@ -199,7 +199,7 @@ public: @throws boost::system::system_error Thrown on failure. @note The `read_some` operation may not read all of the requested number of - bytes. Consider using the function `boost::asio::read` if you need to ensure + bytes. Consider using the function `net::read` if you need to ensure that the requested amount of data is read before the blocking operation completes. */ @@ -220,7 +220,7 @@ public: @returns The number of bytes read. @note The `read_some` operation may not read all of the requested number of - bytes. Consider using the function `boost::asio::read` if you need to ensure + bytes. Consider using the function `net::read` if you need to ensure that the requested amount of data is read before the blocking operation completes. */ @@ -249,7 +249,7 @@ public: ); @endcode @note The `read_some` operation may not read all of the requested number of - bytes. Consider using the function `boost::asio::async_read` if you need + bytes. Consider using the function `net::async_read` if you need to ensure that the requested amount of data is read before the asynchronous operation completes. */ @@ -275,7 +275,7 @@ public: @throws boost::system::system_error Thrown on failure. @note The `write_some` operation may not transmit all of the data to the - peer. Consider using the function `boost::asio::write` if you need to + peer. Consider using the function `net::write` if you need to ensure that all data is written before the blocking operation completes. */ template @@ -295,7 +295,7 @@ public: @returns The number of bytes written. @note The `write_some` operation may not transmit all of the data to the - peer. Consider using the function `boost::asio::write` if you need to + peer. Consider using the function `net::write` if you need to ensure that all data is written before the blocking operation completes. */ template @@ -323,7 +323,7 @@ public: ); @endcode @note The `async_write_some` operation may not transmit all of the data to - the peer. Consider using the function `boost::asio::async_write` if you need + the peer. Consider using the function `net::async_write` if you need to ensure that all data is written before the asynchronous operation completes. */ template< diff --git a/include/boost/beast/_experimental/http/impl/icy_stream.ipp b/include/boost/beast/_experimental/http/impl/icy_stream.ipp index a490fecc..02b8c16a 100644 --- a/include/boost/beast/_experimental/http/impl/icy_stream.ipp +++ b/include/boost/beast/_experimental/http/impl/icy_stream.ipp @@ -103,7 +103,7 @@ public: template typename std::enable_if< - boost::asio::is_dynamic_buffer::value, + net::is_dynamic_buffer::value, dynamic_buffer_ref>::type ref(DynamicBuffer& b) { @@ -114,16 +114,16 @@ template void buffer_shift(MutableBuffers const& out, ConstBuffers const& in) { - using boost::asio::buffer_size; - auto in_pos = boost::asio::buffer_sequence_end(in); - auto out_pos = boost::asio::buffer_sequence_end(out); - auto const in_begin = boost::asio::buffer_sequence_begin(in); - auto const out_begin = boost::asio::buffer_sequence_begin(out); + using net::buffer_size; + auto in_pos = net::buffer_sequence_end(in); + auto out_pos = net::buffer_sequence_end(out); + auto const in_begin = net::buffer_sequence_begin(in); + auto const out_begin = net::buffer_sequence_begin(out); BOOST_ASSERT(buffer_size(in) == buffer_size(out)); if(in_pos == in_begin || out_pos == out_begin) return; - boost::asio::const_buffer cb{*--in_pos}; - boost::asio::mutable_buffer mb{*--out_pos}; + net::const_buffer cb{*--in_pos}; + net::mutable_buffer mb{*--out_pos}; for(;;) { if(mb.size() >= cb.size()) @@ -133,7 +133,7 @@ buffer_shift(MutableBuffers const& out, ConstBuffers const& in) mb.data()) + mb.size() - cb.size(), cb.data(), cb.size()); - mb = boost::asio::mutable_buffer{ + mb = net::mutable_buffer{ mb.data(), mb.size() - cb.size()}; if(in_pos == in_begin) break; @@ -146,7 +146,7 @@ buffer_shift(MutableBuffers const& out, ConstBuffers const& in) static_cast( cb.data()) + cb.size() - mb.size(), mb.size()); - cb = boost::asio::const_buffer{ + cb = net::const_buffer{ cb.data(), cb.size() - mb.size()}; if(out_pos == out_begin) break; @@ -194,14 +194,14 @@ public: template template class icy_stream::read_op - : public boost::asio::coroutine + : public net::coroutine { using alloc_type = typename #if defined(BOOST_NO_CXX11_ALLOCATOR) - boost::asio::associated_allocator_t::template + net::associated_allocator_t::template rebind::other; #else - std::allocator_traits> + std::allocator_traits> ::template rebind_alloc; #endif @@ -237,21 +237,21 @@ public: } using allocator_type = - boost::asio::associated_allocator_t; + net::associated_allocator_t; allocator_type get_allocator() const noexcept { - return (boost::asio::get_associated_allocator)(d_.handler()); + return (net::get_associated_allocator)(d_.handler()); } - using executor_type = boost::asio::associated_executor_t< + using executor_type = net::associated_executor_t< Handler, decltype(std::declval().get_executor())>; executor_type get_executor() const noexcept { - return (boost::asio::get_associated_executor)( + return (net::get_associated_executor)( d_.handler(), d_->s.get_executor()); } @@ -264,7 +264,7 @@ public: friend void asio_handler_invoke(Function&& f, read_op* op) { - using boost::asio::asio_handler_invoke; + using net::asio_handler_invoke; asio_handler_invoke(f, std::addressof(op->d_.handler())); } }; @@ -278,9 +278,9 @@ operator()( error_code ec, std::size_t bytes_transferred) { - using boost::asio::buffer_copy; - using boost::asio::buffer_size; - using iterator = boost::asio::buffers_iterator< + using net::buffer_copy; + using net::buffer_size; + using iterator = net::buffers_iterator< typename detail::dynamic_buffer_ref< buffers_adapter>::const_buffers_type>; auto& d = *d_; @@ -289,7 +289,7 @@ operator()( if(d.b.max_size() == 0) { BOOST_ASIO_CORO_YIELD - boost::asio::post(d.s.get_executor(), + net::post(d.s.get_executor(), beast::bind_handler(std::move(*this), ec, 0)); goto upcall; } @@ -300,7 +300,7 @@ operator()( auto const n = buffer_copy( d.b.prepare(std::min( d.s.copy_, d.b.max_size())), - boost::asio::buffer(d.s.buf_)); + net::buffer(d.s.buf_)); d.b.commit(n); d.s.copy_ = static_cast( d.s.copy_ - n); @@ -326,9 +326,9 @@ operator()( if(d.b.max_size() < 8) { BOOST_ASIO_CORO_YIELD - boost::asio::async_read( + net::async_read( d.s.next_layer(), - boost::asio::buffer(d.s.buf_, 3), + net::buffer(d.s.buf_, 3), std::move(*this)); if(ec) goto upcall; @@ -341,7 +341,7 @@ operator()( { buffer_copy( d.b.value(), - boost::asio::buffer(d.s.buf_, n)); + net::buffer(d.s.buf_, n)); if(d.b.max_size() < 3) { d.s.copy_ = static_cast( @@ -358,7 +358,7 @@ operator()( } d.s.copy_ = static_cast( buffer_copy( - boost::asio::buffer(d.s.buf_), + net::buffer(d.s.buf_), icy_stream::version() + d.b.max_size())); bytes_transferred = buffer_copy( d.b.value(), @@ -367,7 +367,7 @@ operator()( } BOOST_ASIO_CORO_YIELD - boost::asio::async_read_until( + net::async_read_until( d.s.next_layer(), detail::ref(d.b), detail::match_icy(d.match), @@ -384,8 +384,8 @@ operator()( d.s.copy_ = static_cast( n + 5 - d.b.max_size()); std::copy( - boost::asio::buffers_begin(d.b.value()) + n - d.s.copy_, - boost::asio::buffers_begin(d.b.value()) + n, + net::buffers_begin(d.b.value()) + n - d.s.copy_, + net::buffers_begin(d.b.value()) + n, d.s.buf_); n = d.b.max_size() - 5; } @@ -425,7 +425,7 @@ read_some(MutableBufferSequence const& buffers) { static_assert(boost::beast::is_sync_read_stream::value, "SyncReadStream requirements not met"); - static_assert(boost::asio::is_mutable_buffer_sequence< + static_assert(net::is_mutable_buffer_sequence< MutableBufferSequence>::value, "MutableBufferSequence requirements not met"); error_code ec; @@ -443,12 +443,12 @@ read_some(MutableBufferSequence const& buffers, error_code& ec) { static_assert(boost::beast::is_sync_read_stream::value, "SyncReadStream requirements not met"); - static_assert(boost::asio::is_mutable_buffer_sequence< + static_assert(net::is_mutable_buffer_sequence< MutableBufferSequence>::value, "MutableBufferSequence requirements not met"); - using boost::asio::buffer_copy; - using boost::asio::buffer_size; - using iterator = boost::asio::buffers_iterator< + using net::buffer_copy; + using net::buffer_size; + using iterator = net::buffers_iterator< typename detail::dynamic_buffer_ref< buffers_adapter>::const_buffers_type>; buffers_adapter b(buffers); @@ -464,7 +464,7 @@ read_some(MutableBufferSequence const& buffers, error_code& ec) auto const n = buffer_copy( b.prepare(std::min( copy_, b.max_size())), - boost::asio::buffer(buf_)); + net::buffer(buf_)); b.commit(n); copy_ = static_cast( copy_ - n); @@ -483,9 +483,9 @@ read_some(MutableBufferSequence const& buffers, error_code& ec) detect_ = false; if(b.max_size() < 8) { - auto n = boost::asio::read( + auto n = net::read( stream_, - boost::asio::buffer(buf_, 3), + net::buffer(buf_, 3), ec); if(ec) return 0; @@ -497,7 +497,7 @@ read_some(MutableBufferSequence const& buffers, error_code& ec) { buffer_copy( buffers, - boost::asio::buffer(buf_, n)); + net::buffer(buf_, n)); if(b.max_size() < 3) { copy_ = static_cast( @@ -512,7 +512,7 @@ read_some(MutableBufferSequence const& buffers, error_code& ec) } copy_ = static_cast( buffer_copy( - boost::asio::buffer(buf_), + net::buffer(buf_), version() + b.max_size())); return buffer_copy( buffers, @@ -520,7 +520,7 @@ read_some(MutableBufferSequence const& buffers, error_code& ec) } bool match = false; - auto n = boost::asio::read_until( + auto n = net::read_until( stream_, detail::ref(b), detail::match_icy(match), @@ -535,8 +535,8 @@ read_some(MutableBufferSequence const& buffers, error_code& ec) copy_ = static_cast( n + 5 - b.max_size()); std::copy( - boost::asio::buffers_begin(buffers) + n - copy_, - boost::asio::buffers_begin(buffers) + n, + net::buffers_begin(buffers) + n - copy_, + net::buffers_begin(buffers) + n, buf_); n = b.max_size() - 5; } @@ -565,7 +565,7 @@ async_read_some( { static_assert(boost::beast::is_async_read_stream::value, "AsyncReadStream requirements not met"); - static_assert(boost::asio::is_mutable_buffer_sequence< + static_assert(net::is_mutable_buffer_sequence< MutableBufferSequence >::value, "MutableBufferSequence requirements not met"); BOOST_BEAST_HANDLER_INIT( @@ -587,7 +587,7 @@ write_some(MutableBufferSequence const& buffers) { static_assert(boost::beast::is_sync_write_stream::value, "SyncWriteStream requirements not met"); - static_assert(boost::asio::is_const_buffer_sequence< + static_assert(net::is_const_buffer_sequence< MutableBufferSequence>::value, "MutableBufferSequence requirements not met"); return stream_.write_some(buffers); @@ -601,7 +601,7 @@ write_some(MutableBufferSequence const& buffers, error_code& ec) { static_assert(boost::beast::is_sync_write_stream::value, "SyncWriteStream requirements not met"); - static_assert(boost::asio::is_const_buffer_sequence< + static_assert(net::is_const_buffer_sequence< MutableBufferSequence>::value, "MutableBufferSequence requirements not met"); return stream_.write_some(buffers, ec); @@ -620,7 +620,7 @@ async_write_some( { static_assert(boost::beast::is_async_write_stream::value, "AsyncWriteStream requirements not met"); - static_assert(boost::asio::is_const_buffer_sequence< + static_assert(net::is_const_buffer_sequence< MutableBufferSequence>::value, "MutableBufferSequence requirements not met"); return stream_.async_write_some(buffers, std::forward(handler)); diff --git a/include/boost/beast/_experimental/test/impl/stream.ipp b/include/boost/beast/_experimental/test/impl/stream.ipp index 61d88433..caaf86d8 100644 --- a/include/boost/beast/_experimental/test/impl/stream.ipp +++ b/include/boost/beast/_experimental/test/impl/stream.ipp @@ -62,7 +62,7 @@ operator=(stream&& other) inline stream:: -stream(boost::asio::io_context& ioc) +stream(net::io_context& ioc) : in_(std::make_shared(ioc, nullptr)) { } @@ -70,7 +70,7 @@ stream(boost::asio::io_context& ioc) inline stream:: stream( - boost::asio::io_context& ioc, + net::io_context& ioc, fail_count& fc) : in_(std::make_shared(ioc, &fc)) { @@ -79,12 +79,12 @@ stream( inline stream:: stream( - boost::asio::io_context& ioc, + net::io_context& ioc, string_view s) : in_(std::make_shared(ioc, nullptr)) { - using boost::asio::buffer; - using boost::asio::buffer_copy; + using net::buffer; + using net::buffer_copy; in_->b.commit(buffer_copy( in_->b.prepare(s.size()), buffer(s.data(), s.size()))); @@ -93,13 +93,13 @@ stream( inline stream:: stream( - boost::asio::io_context& ioc, + net::io_context& ioc, fail_count& fc, string_view s) : in_(std::make_shared(ioc, &fc)) { - using boost::asio::buffer; - using boost::asio::buffer_copy; + using net::buffer; + using net::buffer_copy; in_->b.commit(buffer_copy( in_->b.prepare(s.size()), buffer(s.data(), s.size()))); @@ -121,7 +121,7 @@ stream:: str() const { auto const bs = in_->b.data(); - if(boost::asio::buffer_size(bs) == 0) + if(net::buffer_size(bs) == 0) return {}; auto const b = buffers_front(bs); return {static_cast(b.data()), b.size()}; @@ -132,8 +132,8 @@ void stream:: append(string_view s) { - using boost::asio::buffer; - using boost::asio::buffer_copy; + using net::buffer; + using net::buffer_copy; std::lock_guard lock{in_->m}; in_->b.commit(buffer_copy( in_->b.prepare(s.size()), @@ -184,7 +184,7 @@ std::size_t stream:: read_some(MutableBufferSequence const& buffers) { - static_assert(boost::asio::is_mutable_buffer_sequence< + static_assert(net::is_mutable_buffer_sequence< MutableBufferSequence>::value, "MutableBufferSequence requirements not met"); error_code ec; @@ -200,11 +200,11 @@ stream:: read_some(MutableBufferSequence const& buffers, error_code& ec) { - static_assert(boost::asio::is_mutable_buffer_sequence< + static_assert(net::is_mutable_buffer_sequence< MutableBufferSequence>::value, "MutableBufferSequence requirements not met"); - using boost::asio::buffer_copy; - using boost::asio::buffer_size; + using net::buffer_copy; + using net::buffer_size; if(in_->fc && in_->fc->fail(ec)) return 0; if(buffer_size(buffers) == 0) @@ -234,9 +234,9 @@ read_some(MutableBufferSequence const& buffers, BOOST_ASSERT(in_->code != status::ok); bytes_transferred = 0; if(in_->code == status::eof) - ec = boost::asio::error::eof; + ec = net::error::eof; else if(in_->code == status::reset) - ec = boost::asio::error::connection_reset; + ec = net::error::connection_reset; } ++in_->nread; return bytes_transferred; @@ -250,18 +250,18 @@ async_read_some( MutableBufferSequence const& buffers, ReadHandler&& handler) { - static_assert(boost::asio::is_mutable_buffer_sequence< + static_assert(net::is_mutable_buffer_sequence< MutableBufferSequence>::value, "MutableBufferSequence requirements not met"); - using boost::asio::buffer_copy; - using boost::asio::buffer_size; + using net::buffer_copy; + using net::buffer_size; BOOST_BEAST_HANDLER_INIT( ReadHandler, void(error_code, std::size_t)); error_code ec; if(in_->fc && in_->fc->fail(ec)) { - boost::asio::post( + net::post( in_->ioc.get_executor(), beast::bind_front_handler( std::move(init.completion_handler), @@ -280,7 +280,7 @@ async_read_some( in_->b.consume(bytes_transferred); lock.unlock(); ++in_->nread; - boost::asio::post( + net::post( in_->ioc.get_executor(), beast::bind_front_handler( std::move(init.completion_handler), @@ -292,10 +292,10 @@ async_read_some( lock.unlock(); ++in_->nread; if(in_->code == status::eof) - ec = boost::asio::error::eof; + ec = net::error::eof; else if(in_->code == status::reset) - ec = boost::asio::error::connection_reset; - boost::asio::post( + ec = net::error::connection_reset; + net::post( in_->ioc.get_executor(), beast::bind_front_handler( std::move(init.completion_handler), @@ -318,7 +318,7 @@ std::size_t stream:: write_some(ConstBufferSequence const& buffers) { - static_assert(boost::asio::is_const_buffer_sequence< + static_assert(net::is_const_buffer_sequence< ConstBufferSequence>::value, "ConstBufferSequence requirements not met"); error_code ec; @@ -335,15 +335,15 @@ stream:: write_some( ConstBufferSequence const& buffers, error_code& ec) { - static_assert(boost::asio::is_const_buffer_sequence< + static_assert(net::is_const_buffer_sequence< ConstBufferSequence>::value, "ConstBufferSequence requirements not met"); - using boost::asio::buffer_copy; - using boost::asio::buffer_size; + using net::buffer_copy; + using net::buffer_size; auto out = out_.lock(); if(! out) { - ec = boost::asio::error::connection_reset; + ec = net::error::connection_reset; return 0; } BOOST_ASSERT(out->code == status::ok); @@ -369,21 +369,21 @@ stream:: async_write_some(ConstBufferSequence const& buffers, WriteHandler&& handler) { - static_assert(boost::asio::is_const_buffer_sequence< + static_assert(net::is_const_buffer_sequence< ConstBufferSequence>::value, "ConstBufferSequence requirements not met"); - using boost::asio::buffer_copy; - using boost::asio::buffer_size; + using net::buffer_copy; + using net::buffer_size; BOOST_BEAST_HANDLER_INIT( WriteHandler, void(error_code, std::size_t)); auto out = out_.lock(); if(! out) { - boost::asio::post( + net::post( in_->ioc.get_executor(), beast::bind_front_handler( std::move(init.completion_handler), - boost::asio::error::connection_reset, + net::error::connection_reset, 0)); } else @@ -392,7 +392,7 @@ async_write_some(ConstBufferSequence const& buffers, error_code ec; if(in_->fc && in_->fc->fail(ec)) { - boost::asio::post( + net::post( in_->ioc.get_executor(), beast::bind_front_handler( std::move(init.completion_handler), @@ -410,7 +410,7 @@ async_write_some(ConstBufferSequence const& buffers, out->on_write(); lock.unlock(); ++in_->nwrite; - boost::asio::post( + net::post( in_->ioc.get_executor(), beast::bind_front_handler( std::move(init.completion_handler), @@ -437,7 +437,7 @@ boost::system::error_code& ec) if( s.in_->fc && s.in_->fc->fail(ec)) - ec = boost::asio::error::eof; + ec = net::error::eof; else ec.assign(0, ec.category()); } @@ -453,17 +453,17 @@ TeardownHandler&& handler) error_code ec; if( s.in_->fc && s.in_->fc->fail(ec)) - return boost::asio::post( + return net::post( s.get_executor(), beast::bind_front_handler(std::move(handler), ec)); s.close(); if( s.in_->fc && s.in_->fc->fail(ec)) - ec = boost::asio::error::eof; + ec = net::error::eof; else ec.assign(0, ec.category()); - boost::asio::post( + net::post( s.get_executor(), beast::bind_front_handler(std::move(handler), ec)); } @@ -478,8 +478,8 @@ class stream::read_op : public stream::read_op_base state& s_; Buffers b_; Handler h_; - boost::asio::executor_work_guard< - boost::asio::io_context::executor_type> work_; + net::executor_work_guard< + net::io_context::executor_type> work_; public: lambda(lambda&&) = default; @@ -497,7 +497,7 @@ class stream::read_op : public stream::read_op_base void post() { - boost::asio::post( + net::post( s_.ioc.get_executor(), std::move(*this)); work_.reset(); @@ -506,8 +506,8 @@ class stream::read_op : public stream::read_op_base void operator()() { - using boost::asio::buffer_copy; - using boost::asio::buffer_size; + using net::buffer_copy; + using net::buffer_size; std::unique_lock lock{s_.m}; BOOST_ASSERT(! s_.op); if(s_.b.size() > 0) @@ -519,7 +519,7 @@ class stream::read_op : public stream::read_op_base Handler h{std::move(h_)}; lock.unlock(); ++s.nread; - boost::asio::post( + net::post( s.ioc.get_executor(), beast::bind_front_handler( std::move(h), @@ -535,10 +535,10 @@ class stream::read_op : public stream::read_op_base ++s.nread; error_code ec; if(s.code == status::eof) - ec = boost::asio::error::eof; + ec = net::error::eof; else if(s.code == status::reset) - ec = boost::asio::error::connection_reset; - boost::asio::post( + ec = net::error::connection_reset; + net::post( s.ioc.get_executor(), beast::bind_front_handler(std::move(h), ec, 0)); } diff --git a/include/boost/beast/_experimental/test/stream.hpp b/include/boost/beast/_experimental/test/stream.hpp index a2992023..fa2ef6dd 100644 --- a/include/boost/beast/_experimental/test/stream.hpp +++ b/include/boost/beast/_experimental/test/stream.hpp @@ -49,11 +49,11 @@ namespace test { These streams may be used anywhere an algorithm accepts a reference to a synchronous or asynchronous read or write stream. It is possible to use a test stream in a call to - `boost::asio::read_until`, or in a call to + `net::read_until`, or in a call to @ref boost::beast::http::async_write for example. As with Boost.Asio I/O objects, a @ref stream constructs - with a reference to the `boost::asio::io_context` to use for + with a reference to the `net::io_context` to use for handling asynchronous I/O. For asynchronous operations, the stream follows the same rules as a traditional asio socket with respect to how completion handlers for asynchronous @@ -120,7 +120,7 @@ class stream flat_buffer b; std::condition_variable cv; std::unique_ptr op; - boost::asio::io_context& ioc; + net::io_context& ioc; status code = status::ok; fail_count* fc = nullptr; std::size_t nread = 0; @@ -137,7 +137,7 @@ class stream explicit state( - boost::asio::io_context& ioc_, + net::io_context& ioc_, fail_count* fc_) : ioc(ioc_) , fc(fc_) @@ -175,7 +175,7 @@ public: handler. If a connection is established while the stream is destroyed, - the peer will see the error `boost::asio::error::connection_reset` + the peer will see the error `net::error::connection_reset` when performing any reads or writes. */ ~stream(); @@ -203,7 +203,7 @@ public: dispatch handlers for any asynchronous operations. */ explicit - stream(boost::asio::io_context& ioc); + stream(net::io_context& ioc); /** Construct a stream @@ -218,7 +218,7 @@ public: a simulated failure error will be raised. */ stream( - boost::asio::io_context& ioc, + net::io_context& ioc, fail_count& fc); /** Construct a stream @@ -232,7 +232,7 @@ public: including the null terminator. */ stream( - boost::asio::io_context& ioc, + net::io_context& ioc, string_view s); /** Construct a stream @@ -251,7 +251,7 @@ public: including the null terminator. */ stream( - boost::asio::io_context& ioc, + net::io_context& ioc, fail_count& fc, string_view s); @@ -261,10 +261,10 @@ public: /// The type of the executor associated with the object. using executor_type = - boost::asio::io_context::executor_type; + net::io_context::executor_type; /// Return the executor associated with the object. - boost::asio::io_context::executor_type + net::io_context::executor_type get_executor() noexcept { return in_->ioc.get_executor(); @@ -374,7 +374,7 @@ public: @throws boost::system::system_error Thrown on failure. @note The `read_some` operation may not read all of the requested number of - bytes. Consider using the function `boost::asio::read` if you need to ensure + bytes. Consider using the function `net::read` if you need to ensure that the requested amount of data is read before the blocking operation completes. */ @@ -395,7 +395,7 @@ public: @returns The number of bytes read. @note The `read_some` operation may not read all of the requested number of - bytes. Consider using the function `boost::asio::read` if you need to ensure + bytes. Consider using the function `net::read` if you need to ensure that the requested amount of data is read before the blocking operation completes. */ @@ -423,7 +423,7 @@ public: ); @endcode @note The `read_some` operation may not read all of the requested number of - bytes. Consider using the function `boost::asio::async_read` if you need + bytes. Consider using the function `net::async_read` if you need to ensure that the requested amount of data is read before the asynchronous operation completes. */ @@ -446,7 +446,7 @@ public: @throws boost::system::system_error Thrown on failure. @note The `write_some` operation may not transmit all of the data to the - peer. Consider using the function `boost::asio::write` if you need to + peer. Consider using the function `net::write` if you need to ensure that all data is written before the blocking operation completes. */ template @@ -466,7 +466,7 @@ public: @returns The number of bytes written. @note The `write_some` operation may not transmit all of the data to the - peer. Consider using the function `boost::asio::write` if you need to + peer. Consider using the function `net::write` if you need to ensure that all data is written before the blocking operation completes. */ template @@ -493,7 +493,7 @@ public: ); @endcode @note The `async_write_some` operation may not transmit all of the data to - the peer. Consider using the function `boost::asio::async_write` if you need + the peer. Consider using the function `net::async_write` if you need to ensure that all data is written before the asynchronous operation completes. */ template diff --git a/include/boost/beast/core/bind_handler.hpp b/include/boost/beast/core/bind_handler.hpp index 89fb8437..40b55dac 100644 --- a/include/boost/beast/core/bind_handler.hpp +++ b/include/boost/beast/core/bind_handler.hpp @@ -38,10 +38,10 @@ namespace beast { void signal_aborted(AsyncReadStream& stream, ReadHandler&& handler) { - boost::asio::post( + net::post( stream.get_executor(), bind_handler(std::forward(handler), - boost::asio::error::operation_aborted, 0)); + net::error::operation_aborted, 0)); } @endcode @@ -90,10 +90,10 @@ bind_handler(Handler&& handler, Args&&... args) void signal_aborted(AsyncReadStream& stream, ReadHandler&& handler) { - boost::asio::post( + net::post( stream.get_executor(), bind_front_handler(std::forward(handler), - boost::asio::error::operation_aborted, 0)); + net::error::operation_aborted, 0)); } @endcode diff --git a/include/boost/beast/core/buffered_read_stream.hpp b/include/boost/beast/core/buffered_read_stream.hpp index 2c975b14..db873854 100644 --- a/include/boost/beast/core/buffered_read_stream.hpp +++ b/include/boost/beast/core/buffered_read_stream.hpp @@ -31,17 +31,17 @@ namespace beast { is part of the object. The use-case for this class is different than that of the - `boost::asio::buffered_readstream`. It is designed to facilitate - the use of `boost::asio::read_until`, and to allow buffers + `net::buffered_readstream`. It is designed to facilitate + the use of `net::read_until`, and to allow buffers acquired during detection of handshakes to be made transparently available to callers. A hypothetical implementation of the - buffered version of `boost::asio::ssl::stream::async_handshake` + buffered version of `net::ssl::stream::async_handshake` could make use of this wrapper. Uses: @li Transparently leave untouched input acquired in calls - to `boost::asio::read_until` behind for subsequent callers. + to `net::read_until` behind for subsequent callers. @li "Preload" a stream with handshake input data acquired from other sources. @@ -62,7 +62,7 @@ namespace beast { // part up to the end of the delimiter. // std::size_t bytes_transferred = - boost::asio::read_until( + net::read_until( stream.next_layer(), stream.buffer(), "\r\n\r\n"); // Use buffers_prefix() to limit the input @@ -92,7 +92,7 @@ template class buffered_read_stream { static_assert( - boost::asio::is_dynamic_buffer::value, + net::is_dynamic_buffer::value, "DynamicBuffer requirements not met"); template @@ -283,7 +283,7 @@ public: Regardless of whether the asynchronous operation completes immediately or not, the handler will not be invoked from within this function. Invocation of the handler will be performed in a - manner equivalent to using `boost::asio::io_context::post`. + manner equivalent to using `net::io_context::post`. */ template BOOST_ASIO_INITFN_RESULT_TYPE( @@ -355,7 +355,7 @@ public: Regardless of whether the asynchronous operation completes immediately or not, the handler will not be invoked from within this function. Invocation of the handler will be performed in a - manner equivalent to using `boost::asio::io_context::post`. + manner equivalent to using `net::io_context::post`. */ template BOOST_ASIO_INITFN_RESULT_TYPE( diff --git a/include/boost/beast/core/buffers_adapter.hpp b/include/boost/beast/core/buffers_adapter.hpp index a5451818..660d0db8 100644 --- a/include/boost/beast/core/buffers_adapter.hpp +++ b/include/boost/beast/core/buffers_adapter.hpp @@ -36,7 +36,7 @@ namespace beast { template class buffers_adapter { - static_assert(boost::asio::is_mutable_buffer_sequence::value, + static_assert(net::is_mutable_buffer_sequence::value, "MutableBufferSequence requirements not met"); using iter_type = typename diff --git a/include/boost/beast/core/buffers_cat.hpp b/include/boost/beast/core/buffers_cat.hpp index 14e7ecb8..2befd0b3 100644 --- a/include/boost/beast/core/buffers_cat.hpp +++ b/include/boost/beast/core/buffers_cat.hpp @@ -30,8 +30,8 @@ public: /** The type of buffer returned when dereferencing an iterator. If every buffer sequence in the view is a @b MutableBufferSequence, - then `value_type` will be `boost::asio::mutable_buffer`. - Otherwise, `value_type` will be `boost::asio::const_buffer`. + then `value_type` will be `net::mutable_buffer`. + Otherwise, `value_type` will be `net::const_buffer`. */ #if BOOST_BEAST_DOXYGEN using value_type = __implementation_defined__; diff --git a/include/boost/beast/core/buffers_prefix.hpp b/include/boost/beast/core/buffers_prefix.hpp index f606b309..e85596fa 100644 --- a/include/boost/beast/core/buffers_prefix.hpp +++ b/include/boost/beast/core/buffers_prefix.hpp @@ -60,9 +60,9 @@ public: using value_type = typename std::conditional< std::is_convertible::value_type, - boost::asio::mutable_buffer>::value, - boost::asio::mutable_buffer, - boost::asio::const_buffer>::type; + net::mutable_buffer>::value, + net::mutable_buffer, + net::const_buffer>::type; #if BOOST_BEAST_DOXYGEN /// A bidirectional iterator type that may be used to read elements. @@ -139,9 +139,9 @@ public: bytes of the original buffer. */ inline -boost::asio::const_buffer +net::const_buffer buffers_prefix(std::size_t size, - boost::asio::const_buffer buffer) + net::const_buffer buffer) { return {buffer.data(), (std::min)(size, buffer.size())}; @@ -162,9 +162,9 @@ buffers_prefix(std::size_t size, of the original buffer. */ inline -boost::asio::mutable_buffer +net::mutable_buffer buffers_prefix(std::size_t size, - boost::asio::mutable_buffer buffer) + net::mutable_buffer buffer) { return {buffer.data(), (std::min)(size, buffer.size())}; @@ -193,16 +193,16 @@ buffers_prefix_view inline typename std::enable_if< ! std::is_same::value && + net::const_buffer>::value && ! std::is_same::value, + net::mutable_buffer>::value, buffers_prefix_view>::type #endif buffers_prefix(std::size_t size, BufferSequence const& buffers) { static_assert( - boost::asio::is_const_buffer_sequence::value || - boost::asio::is_mutable_buffer_sequence::value, + net::is_const_buffer_sequence::value || + net::is_mutable_buffer_sequence::value, "BufferSequence requirements not met"); return buffers_prefix_view(size, buffers); } @@ -219,14 +219,14 @@ buffers_prefix(std::size_t size, BufferSequence const& buffers) */ template typename std::conditional< - boost::asio::is_mutable_buffer_sequence::value, - boost::asio::mutable_buffer, - boost::asio::const_buffer>::type + net::is_mutable_buffer_sequence::value, + net::mutable_buffer, + net::const_buffer>::type buffers_front(BufferSequence const& buffers) { auto const first = - boost::asio::buffer_sequence_begin(buffers); - if(first == boost::asio::buffer_sequence_end(buffers)) + net::buffer_sequence_begin(buffers); + if(first == net::buffer_sequence_end(buffers)) return {}; return *first; } diff --git a/include/boost/beast/core/buffers_range.hpp b/include/boost/beast/core/buffers_range.hpp index a0d4a661..3eb24492 100644 --- a/include/boost/beast/core/buffers_range.hpp +++ b/include/boost/beast/core/buffers_range.hpp @@ -64,7 +64,7 @@ detail::buffers_range_adaptor buffers_range(ConstBufferSequence const& buffers) { static_assert( - boost::asio::is_const_buffer_sequence::value, + net::is_const_buffer_sequence::value, "ConstBufferSequence requirements not met"); return detail::buffers_range_adaptor(buffers); } @@ -78,7 +78,7 @@ detail::buffers_range_adaptor buffers_range(std::reference_wrapper buffers) { static_assert( - boost::asio::is_const_buffer_sequence::value, + net::is_const_buffer_sequence::value, "ConstBufferSequence requirements not met"); return detail::buffers_range_adaptor(buffers.get()); } diff --git a/include/boost/beast/core/buffers_suffix.hpp b/include/boost/beast/core/buffers_suffix.hpp index bbdf72f4..101b8d2a 100644 --- a/include/boost/beast/core/buffers_suffix.hpp +++ b/include/boost/beast/core/buffers_suffix.hpp @@ -45,7 +45,7 @@ namespace beast { void send(SyncWriteStream& stream, ConstBufferSequence const& buffers) { buffers_suffix bs{buffers}; - while(boost::asio::buffer_size(bs) > 0) + while(net::buffer_size(bs) > 0) bs.consume(stream.write_some(bs)); } @endcode @@ -67,7 +67,7 @@ class buffers_suffix buffers_suffix(Deduced&& other, std::size_t dist) : bs_(std::forward(other).bs_) , begin_(std::next( - boost::asio::buffer_sequence_begin(bs_), + net::buffer_sequence_begin(bs_), dist)) , skip_(other.skip_) { @@ -77,9 +77,9 @@ public: /** The type for each element in the list of buffers. If the buffers in the underlying sequence are convertible to - `boost::asio::mutable_buffer`, then this type will be - `boost::asio::mutable_buffer`, else this type will be - `boost::asio::const_buffer`. + `net::mutable_buffer`, then this type will be + `net::mutable_buffer`, else this type will be + `net::const_buffer`. */ #if BOOST_BEAST_DOXYGEN using value_type = __implementation_defined__; @@ -87,9 +87,9 @@ public: using value_type = typename std::conditional< std::is_convertible::value_type, - boost::asio::mutable_buffer>::value, - boost::asio::mutable_buffer, - boost::asio::const_buffer>::type; + net::mutable_buffer>::value, + net::mutable_buffer, + net::const_buffer>::type; #endif #if BOOST_BEAST_DOXYGEN diff --git a/include/boost/beast/core/buffers_to_string.hpp b/include/boost/beast/core/buffers_to_string.hpp index 8bd659ce..726342c2 100644 --- a/include/boost/beast/core/buffers_to_string.hpp +++ b/include/boost/beast/core/buffers_to_string.hpp @@ -45,10 +45,10 @@ std::string buffers_to_string(ConstBufferSequence const& buffers) { static_assert( - boost::asio::is_const_buffer_sequence::value, + net::is_const_buffer_sequence::value, "ConstBufferSequence requirements not met"); std::string result; - result.reserve(boost::asio::buffer_size(buffers)); + result.reserve(net::buffer_size(buffers)); for(auto const buffer : buffers_range(std::ref(buffers))) result.append(static_cast( buffer.data()), buffer.size()); diff --git a/include/boost/beast/core/detail/bind_handler.hpp b/include/boost/beast/core/detail/bind_handler.hpp index 02338732..42806487 100644 --- a/include/boost/beast/core/detail/bind_handler.hpp +++ b/include/boost/beast/core/detail/bind_handler.hpp @@ -40,7 +40,7 @@ class bind_wrapper // Can't friend partial specializations, // so we just friend the whole thing. template - friend struct boost::asio::associated_executor; + friend struct net::associated_executor; template static @@ -123,7 +123,7 @@ public: using result_type = void; using allocator_type = - boost::asio::associated_allocator_t; + net::associated_allocator_t; bind_wrapper(bind_wrapper&&) = default; bind_wrapper(bind_wrapper const&) = default; @@ -140,14 +140,14 @@ public: allocator_type get_allocator() const noexcept { - return (boost::asio::get_associated_allocator)(h_); + return (net::get_associated_allocator)(h_); } friend bool asio_handler_is_continuation(bind_wrapper* w) { - using boost::asio::asio_handler_is_continuation; + using net::asio_handler_is_continuation; return asio_handler_is_continuation(std::addressof(w->h_)); } @@ -155,7 +155,7 @@ public: friend void asio_handler_invoke(Function&& f, bind_wrapper* w) { - using boost::asio::asio_handler_invoke; + using net::asio_handler_invoke; asio_handler_invoke(f, std::addressof(w->h_)); } @@ -194,13 +194,13 @@ class bind_front_wrapper // Can't friend partial specializations, // so we just friend the whole thing. template - friend struct boost::asio::associated_executor; + friend struct net::associated_executor; public: using result_type = void; using allocator_type = - boost::asio::associated_allocator_t; + net::associated_allocator_t; bind_front_wrapper(bind_front_wrapper&&) = default; bind_front_wrapper(bind_front_wrapper const&) = default; @@ -215,14 +215,14 @@ public: allocator_type get_allocator() const noexcept { - return boost::asio::get_associated_allocator(h_); + return net::get_associated_allocator(h_); } friend bool asio_handler_is_continuation(bind_front_wrapper* w) { - using boost::asio::asio_handler_is_continuation; + using net::asio_handler_is_continuation; return asio_handler_is_continuation(std::addressof(w->h_)); } @@ -230,7 +230,7 @@ public: friend void asio_handler_invoke(Function&& f, bind_front_wrapper* w) { - using boost::asio::asio_handler_invoke; + using net::asio_handler_invoke; asio_handler_invoke(f, std::addressof(w->h_)); } @@ -251,13 +251,13 @@ class bind_front_wrapper // Can't friend partial specializations, // so we just friend the whole thing. template - friend struct boost::asio::associated_executor; + friend struct net::associated_executor; public: using result_type = void; using allocator_type = - boost::asio::associated_allocator_t; + net::associated_allocator_t; bind_front_wrapper(bind_front_wrapper&&) = default; bind_front_wrapper(bind_front_wrapper const&) = default; @@ -273,14 +273,14 @@ public: allocator_type get_allocator() const noexcept { - return boost::asio::get_associated_allocator(h_); + return net::get_associated_allocator(h_); } friend bool asio_handler_is_continuation(bind_front_wrapper* w) { - using boost::asio::asio_handler_is_continuation; + using net::asio_handler_is_continuation; return asio_handler_is_continuation(std::addressof(w->h_)); } @@ -288,7 +288,7 @@ public: friend void asio_handler_invoke(Function&& f, bind_front_wrapper* w) { - using boost::asio::asio_handler_invoke; + using net::asio_handler_invoke; asio_handler_invoke(f, std::addressof(w->h_)); } @@ -311,13 +311,13 @@ class bind_front_wrapper // Can't friend partial specializations, // so we just friend the whole thing. template - friend struct boost::asio::associated_executor; + friend struct net::associated_executor; public: using result_type = void; using allocator_type = - boost::asio::associated_allocator_t; + net::associated_allocator_t; bind_front_wrapper(bind_front_wrapper&&) = default; bind_front_wrapper(bind_front_wrapper const&) = default; @@ -334,14 +334,14 @@ public: allocator_type get_allocator() const noexcept { - return boost::asio::get_associated_allocator(h_); + return net::get_associated_allocator(h_); } friend bool asio_handler_is_continuation(bind_front_wrapper* w) { - using boost::asio::asio_handler_is_continuation; + using net::asio_handler_is_continuation; return asio_handler_is_continuation(std::addressof(w->h_)); } @@ -349,7 +349,7 @@ public: friend void asio_handler_invoke(Function&& f, bind_front_wrapper* w) { - using boost::asio::asio_handler_invoke; + using net::asio_handler_invoke; asio_handler_invoke(f, std::addressof(w->h_)); } @@ -379,7 +379,7 @@ class bind_front_wrapper // Can't friend partial specializations, // so we just friend the whole thing. template - friend struct boost::asio::associated_executor; + friend struct net::associated_executor; template void @@ -395,7 +395,7 @@ public: using result_type = void; using allocator_type = - boost::asio::associated_allocator_t; + net::associated_allocator_t; bind_front_wrapper(bind_front_wrapper&&) = default; bind_front_wrapper(bind_front_wrapper const&) = default; @@ -416,14 +416,14 @@ public: allocator_type get_allocator() const noexcept { - return boost::asio::get_associated_allocator(h_); + return net::get_associated_allocator(h_); } friend bool asio_handler_is_continuation(bind_front_wrapper* w) { - using boost::asio::asio_handler_is_continuation; + using net::asio_handler_is_continuation; return asio_handler_is_continuation(std::addressof(w->h_)); } @@ -431,7 +431,7 @@ public: friend void asio_handler_invoke(Function&& f, bind_front_wrapper* w) { - using boost::asio::asio_handler_invoke; + using net::asio_handler_invoke; asio_handler_invoke(f, std::addressof(w->h_)); } @@ -461,7 +461,7 @@ public: using result_type = void; using allocator_type = - boost::asio::associated_allocator_t; + net::associated_allocator_t; bind_front_wrapper(bind_front_wrapper&&) = default; bind_front_wrapper(bind_front_wrapper const&) = default; @@ -478,14 +478,14 @@ public: allocator_type get_allocator() const noexcept { - return boost::asio::get_associated_allocator(h_); + return net::get_associated_allocator(h_); } friend bool asio_handler_is_continuation(bind_front_wrapper* w) { - using boost::asio::asio_handler_is_continuation; + using net::asio_handler_is_continuation; return asio_handler_is_continuation(std::addressof(w->h_)); } @@ -493,7 +493,7 @@ public: friend void asio_handler_invoke(Function&& f, bind_front_wrapper* w) { - using boost::asio::asio_handler_invoke; + using net::asio_handler_invoke; asio_handler_invoke(f, std::addressof(w->h_)); } diff --git a/include/boost/beast/core/detail/buffers_range.hpp b/include/boost/beast/core/detail/buffers_range.hpp index 56b1c712..3521f53e 100644 --- a/include/boost/beast/core/detail/buffers_range.hpp +++ b/include/boost/beast/core/detail/buffers_range.hpp @@ -33,9 +33,9 @@ public: typename std::iterator_traits< typename detail::buffer_sequence_iterator< BufferSequence>::type>::value_type, - boost::asio::mutable_buffer>::value, - boost::asio::mutable_buffer, - boost::asio::const_buffer>::type; + net::mutable_buffer>::value, + net::mutable_buffer, + net::const_buffer>::type; #endif class const_iterator @@ -124,13 +124,13 @@ public: const_iterator begin() const noexcept { - return boost::asio::buffer_sequence_begin(b_); + return net::buffer_sequence_begin(b_); } const_iterator end() const noexcept { - return boost::asio::buffer_sequence_end(b_); + return net::buffer_sequence_end(b_); } }; diff --git a/include/boost/beast/core/detail/buffers_ref.hpp b/include/boost/beast/core/detail/buffers_ref.hpp index e56a9764..c2552e08 100644 --- a/include/boost/beast/core/detail/buffers_ref.hpp +++ b/include/boost/beast/core/detail/buffers_ref.hpp @@ -42,13 +42,13 @@ public: const_iterator begin() const { - return boost::asio::buffer_sequence_begin(*buffers_); + return net::buffer_sequence_begin(*buffers_); } const_iterator end() const { - return boost::asio::buffer_sequence_end(*buffers_); + return net::buffer_sequence_end(*buffers_); } }; diff --git a/include/boost/beast/core/detail/type_traits.hpp b/include/boost/beast/core/detail/type_traits.hpp index 0c46efc9..c09a2d49 100644 --- a/include/boost/beast/core/detail/type_traits.hpp +++ b/include/boost/beast/core/detail/type_traits.hpp @@ -262,21 +262,21 @@ struct BufferSequence const_iterator end() const noexcept; }; using ConstBufferSequence = - BufferSequence; + BufferSequence; using MutableBufferSequence = - BufferSequence; + BufferSequence; template struct is_all_const_buffer_sequence : std::integral_constant::value && + net::is_const_buffer_sequence::value && is_all_const_buffer_sequence::value> { }; template struct is_all_const_buffer_sequence - : boost::asio::is_const_buffer_sequence + : net::is_const_buffer_sequence { }; @@ -288,22 +288,22 @@ template struct buffer_sequence_iterator { using type = decltype( - boost::asio::buffer_sequence_begin( + net::buffer_sequence_begin( std::declval())); }; template<> struct buffer_sequence_iterator< - boost::asio::const_buffer> + net::const_buffer> { - using type = boost::asio::const_buffer const*; + using type = net::const_buffer const*; }; template<> struct buffer_sequence_iterator< - boost::asio::mutable_buffer> + net::mutable_buffer> { - using type = boost::asio::mutable_buffer const*; + using type = net::mutable_buffer const*; }; // @@ -320,16 +320,16 @@ struct buffer_sequence_value_type template<> struct buffer_sequence_value_type< - boost::asio::const_buffer const*> + net::const_buffer const*> { - using type = boost::asio::const_buffer; + using type = net::const_buffer; }; template<> struct buffer_sequence_value_type< - boost::asio::mutable_buffer const*> + net::mutable_buffer const*> { - using type = boost::asio::mutable_buffer; + using type = net::mutable_buffer; }; // @@ -341,9 +341,9 @@ struct common_buffers_type mp11::mp_and< boost::is_convertible< typename buffer_sequence_value_type::type, - boost::asio::mutable_buffer>...>::value, - boost::asio::mutable_buffer, - boost::asio::const_buffer>::type; + net::mutable_buffer>...>::value, + net::mutable_buffer, + net::const_buffer>::type; }; // Types that meet the requirements, @@ -366,7 +366,7 @@ using WriteHandler = StreamHandler; static_assert(boost::beast::is_completion_handler< \ BOOST_ASIO_HANDLER_TYPE(type, sig), sig>::value, \ "CompletionHandler signature requirements not met"); \ - boost::asio::async_completion init{handler} + net::async_completion init{handler} } // detail } // beast diff --git a/include/boost/beast/core/flat_buffer.hpp b/include/boost/beast/core/flat_buffer.hpp index 14cc046e..17c4111a 100644 --- a/include/boost/beast/core/flat_buffer.hpp +++ b/include/boost/beast/core/flat_buffer.hpp @@ -281,13 +281,13 @@ public: //-------------------------------------------------------------------------- /// The ConstBufferSequence used to represent the readable bytes. - using const_buffers_type = boost::asio::const_buffer; + using const_buffers_type = net::const_buffer; /// The MutableBufferSequence used to represent the readable bytes. - using mutable_data_type = boost::asio::mutable_buffer; + using mutable_data_type = net::mutable_buffer; /// The MutableBufferSequence used to represent the writable bytes. - using mutable_buffers_type = boost::asio::mutable_buffer; + using mutable_buffers_type = net::mutable_buffer; /// Returns the number of readable bytes. std::size_t diff --git a/include/boost/beast/core/flat_static_buffer.hpp b/include/boost/beast/core/flat_static_buffer.hpp index a4ae62f7..c3bbd223 100644 --- a/include/boost/beast/core/flat_static_buffer.hpp +++ b/include/boost/beast/core/flat_static_buffer.hpp @@ -92,13 +92,13 @@ public: //-------------------------------------------------------------------------- /// The ConstBufferSequence used to represent the readable bytes. - using const_buffers_type = boost::asio::const_buffer; + using const_buffers_type = net::const_buffer; /// The MutableBufferSequence used to represent the readable bytes. - using mutable_data_type = boost::asio::mutable_buffer; + using mutable_data_type = net::mutable_buffer; /// The MutableBufferSequence used to represent the writable bytes. - using mutable_buffers_type = boost::asio::mutable_buffer; + using mutable_buffers_type = net::mutable_buffer; /// Returns the number of readable bytes. std::size_t diff --git a/include/boost/beast/core/impl/buffered_read_stream.ipp b/include/boost/beast/core/impl/buffered_read_stream.ipp index 9ffcb53f..00d96f71 100644 --- a/include/boost/beast/core/impl/buffered_read_stream.ipp +++ b/include/boost/beast/core/impl/buffered_read_stream.ipp @@ -33,7 +33,7 @@ class buffered_read_stream< Stream, DynamicBuffer>::read_some_op { buffered_read_stream& s_; - boost::asio::executor_work_guard().get_executor())> wg_; MutableBufferSequence b_; Handler h_; @@ -55,22 +55,22 @@ public: } using allocator_type = - boost::asio::associated_allocator_t; + net::associated_allocator_t; allocator_type get_allocator() const noexcept { - return (boost::asio::get_associated_allocator)(h_); + return (net::get_associated_allocator)(h_); } using executor_type = - boost::asio::associated_executor_t().get_executor())>; executor_type get_executor() const noexcept { - return (boost::asio::get_associated_executor)( + return (net::get_associated_executor)( h_, s_.get_executor()); } @@ -81,7 +81,7 @@ public: friend bool asio_handler_is_continuation(read_some_op* op) { - using boost::asio::asio_handler_is_continuation; + using net::asio_handler_is_continuation; return asio_handler_is_continuation( std::addressof(op->h_)); } @@ -90,7 +90,7 @@ public: friend void asio_handler_invoke(Function&& f, read_some_op* op) { - using boost::asio::asio_handler_invoke; + using net::asio_handler_invoke; asio_handler_invoke(f, std::addressof(op->h_)); } }; @@ -124,7 +124,7 @@ read_some_op::operator()( } step_ = 3; - return boost::asio::post( + return net::post( s_.get_executor(), beast::bind_front_handler(std::move(*this), ec, 0)); @@ -138,7 +138,7 @@ read_some_op::operator()( case 3: bytes_transferred = - boost::asio::buffer_copy(b_, s_.buffer_.data()); + net::buffer_copy(b_, s_.buffer_.data()); s_.buffer_.consume(bytes_transferred); break; } @@ -166,7 +166,7 @@ async_write_some( { static_assert(is_async_write_stream::value, "AsyncWriteStream requirements not met"); - static_assert(boost::asio::is_const_buffer_sequence< + static_assert(net::is_const_buffer_sequence< ConstBufferSequence>::value, "ConstBufferSequence requirements not met"); static_assert(is_completion_handler::value, "SyncReadStream requirements not met"); - static_assert(boost::asio::is_mutable_buffer_sequence< + static_assert(net::is_mutable_buffer_sequence< MutableBufferSequence>::value, "MutableBufferSequence requirements not met"); error_code ec; @@ -204,11 +204,11 @@ read_some(MutableBufferSequence const& buffers, { static_assert(is_sync_read_stream::value, "SyncReadStream requirements not met"); - static_assert(boost::asio::is_mutable_buffer_sequence< + static_assert(net::is_mutable_buffer_sequence< MutableBufferSequence>::value, "MutableBufferSequence requirements not met"); - using boost::asio::buffer_size; - using boost::asio::buffer_copy; + using net::buffer_size; + using net::buffer_copy; if(buffer_.size() == 0) { if(capacity_ == 0) @@ -240,7 +240,7 @@ async_read_some( { static_assert(is_async_read_stream::value, "AsyncReadStream requirements not met"); - static_assert(boost::asio::is_mutable_buffer_sequence< + static_assert(net::is_mutable_buffer_sequence< MutableBufferSequence>::value, "MutableBufferSequence requirements not met"); if(buffer_.size() == 0 && capacity_ == 0) diff --git a/include/boost/beast/core/impl/buffers_adapter.ipp b/include/boost/beast/core/impl/buffers_adapter.ipp index f077c521..b8eeb82c 100644 --- a/include/boost/beast/core/impl/buffers_adapter.ipp +++ b/include/boost/beast/core/impl/buffers_adapter.ipp @@ -29,7 +29,7 @@ class buffers_adapter:: buffers_adapter const* b_; public: - using value_type = boost::asio::const_buffer; + using value_type = net::const_buffer; class const_iterator; @@ -62,7 +62,7 @@ class buffers_adapter:: buffers_adapter const* b_ = nullptr; public: - using value_type = boost::asio::const_buffer; + using value_type = net::const_buffer; using pointer = value_type const*; using reference = value_type; using difference_type = std::ptrdiff_t; @@ -105,7 +105,7 @@ public: { value_type const b = *it_; return value_type{b.data(), - (b_->out_ == boost::asio::buffer_sequence_end(b_->bs_) || + (b_->out_ == net::buffer_sequence_end(b_->bs_) || it_ != b_->out_) ? b.size() : b_->out_pos_} + (it_ == b_->begin_ ? b_->in_pos_ : 0); } @@ -181,7 +181,7 @@ mutable_buffers_type buffers_adapter const* b_; public: - using value_type = boost::asio::mutable_buffer; + using value_type = net::mutable_buffer; class const_iterator; @@ -215,7 +215,7 @@ mutable_buffers_type::const_iterator buffers_adapter const* b_ = nullptr; public: - using value_type = boost::asio::mutable_buffer; + using value_type = net::mutable_buffer; using pointer = value_type const*; using reference = value_type; using difference_type = std::ptrdiff_t; @@ -344,9 +344,9 @@ template buffers_adapter:: buffers_adapter(buffers_adapter&& other) : buffers_adapter(std::move(other), - std::distance(boost::asio::buffer_sequence_begin(other.bs_), other.begin_), - std::distance(boost::asio::buffer_sequence_begin(other.bs_), other.out_), - std::distance(boost::asio::buffer_sequence_begin(other.bs_), other.end_)) + std::distance(net::buffer_sequence_begin(other.bs_), other.begin_), + std::distance(net::buffer_sequence_begin(other.bs_), other.out_), + std::distance(net::buffer_sequence_begin(other.bs_), other.end_)) { } @@ -354,9 +354,9 @@ template buffers_adapter:: buffers_adapter(buffers_adapter const& other) : buffers_adapter(other, - std::distance(boost::asio::buffer_sequence_begin(other.bs_), other.begin_), - std::distance(boost::asio::buffer_sequence_begin(other.bs_), other.out_), - std::distance(boost::asio::buffer_sequence_begin(other.bs_), other.end_)) + std::distance(net::buffer_sequence_begin(other.bs_), other.begin_), + std::distance(net::buffer_sequence_begin(other.bs_), other.out_), + std::distance(net::buffer_sequence_begin(other.bs_), other.end_)) { } @@ -367,18 +367,18 @@ operator=(buffers_adapter&& other) -> buffers_adapter& { auto const nbegin = std::distance( - boost::asio::buffer_sequence_begin(other.bs_), + net::buffer_sequence_begin(other.bs_), other.begin_); auto const nout = std::distance( - boost::asio::buffer_sequence_begin(other.bs_), + net::buffer_sequence_begin(other.bs_), other.out_); auto const nend = std::distance( - boost::asio::buffer_sequence_begin(other.bs_), + net::buffer_sequence_begin(other.bs_), other.end_); bs_ = std::move(other.bs_); - begin_ = std::next(boost::asio::buffer_sequence_begin(bs_), nbegin); - out_ = std::next(boost::asio::buffer_sequence_begin(bs_), nout); - end_ = std::next(boost::asio::buffer_sequence_begin(bs_), nend); + begin_ = std::next(net::buffer_sequence_begin(bs_), nbegin); + out_ = std::next(net::buffer_sequence_begin(bs_), nout); + end_ = std::next(net::buffer_sequence_begin(bs_), nend); max_size_ = other.max_size_; in_pos_ = other.in_pos_; in_size_ = other.in_size_; @@ -394,18 +394,18 @@ operator=(buffers_adapter const& other) -> buffers_adapter& { auto const nbegin = std::distance( - boost::asio::buffer_sequence_begin(other.bs_), + net::buffer_sequence_begin(other.bs_), other.begin_); auto const nout = std::distance( - boost::asio::buffer_sequence_begin(other.bs_), + net::buffer_sequence_begin(other.bs_), other.out_); auto const nend = std::distance( - boost::asio::buffer_sequence_begin(other.bs_), + net::buffer_sequence_begin(other.bs_), other.end_); bs_ = other.bs_; - begin_ = std::next(boost::asio::buffer_sequence_begin(bs_), nbegin); - out_ = std::next(boost::asio::buffer_sequence_begin(bs_), nout); - end_ = std::next(boost::asio::buffer_sequence_begin(bs_), nend); + begin_ = std::next(net::buffer_sequence_begin(bs_), nbegin); + out_ = std::next(net::buffer_sequence_begin(bs_), nout); + end_ = std::next(net::buffer_sequence_begin(bs_), nend); max_size_ = other.max_size_; in_pos_ = other.in_pos_; in_size_ = other.in_size_; @@ -418,10 +418,10 @@ template buffers_adapter:: buffers_adapter(MutableBufferSequence const& bs) : bs_(bs) - , begin_(boost::asio::buffer_sequence_begin(bs_)) - , out_ (boost::asio::buffer_sequence_begin(bs_)) - , end_ (boost::asio::buffer_sequence_begin(bs_)) - , max_size_(boost::asio::buffer_size(bs_)) + , begin_(net::buffer_sequence_begin(bs_)) + , out_ (net::buffer_sequence_begin(bs_)) + , end_ (net::buffer_sequence_begin(bs_)) + , max_size_(net::buffer_size(bs_)) { } @@ -430,10 +430,10 @@ template buffers_adapter:: buffers_adapter(boost::in_place_init_t, Args&&... args) : bs_{std::forward(args)...} - , begin_(boost::asio::buffer_sequence_begin(bs_)) - , out_ (boost::asio::buffer_sequence_begin(bs_)) - , end_ (boost::asio::buffer_sequence_begin(bs_)) - , max_size_(boost::asio::buffer_size(bs_)) + , begin_(net::buffer_sequence_begin(bs_)) + , out_ (net::buffer_sequence_begin(bs_)) + , end_ (net::buffer_sequence_begin(bs_)) + , max_size_(net::buffer_size(bs_)) { } @@ -443,16 +443,16 @@ buffers_adapter:: prepare(std::size_t n) -> mutable_buffers_type { - using boost::asio::buffer_size; + using net::buffer_size; end_ = out_; - if(end_ != boost::asio::buffer_sequence_end(bs_)) + if(end_ != net::buffer_sequence_end(bs_)) { auto size = buffer_size(*end_) - out_pos_; if(n > size) { n -= size; while(++end_ != - boost::asio::buffer_sequence_end(bs_)) + net::buffer_sequence_end(bs_)) { size = buffer_size(*end_); if(n < size) @@ -484,7 +484,7 @@ void buffers_adapter:: commit(std::size_t n) { - using boost::asio::buffer_size; + using net::buffer_size; if(out_ == end_) return; auto const last = std::prev(end_); @@ -530,7 +530,7 @@ void buffers_adapter:: consume(std::size_t n) { - using boost::asio::buffer_size; + using net::buffer_size; while(begin_ != out_) { auto const avail = diff --git a/include/boost/beast/core/impl/buffers_cat.ipp b/include/boost/beast/core/impl/buffers_cat.ipp index d1594574..b1b5ec2e 100644 --- a/include/boost/beast/core/impl/buffers_cat.ipp +++ b/include/boost/beast/core/impl/buffers_cat.ipp @@ -32,7 +32,7 @@ struct buffers_cat_view_iterator_base { char unused = 0; // make g++8 happy - boost::asio::mutable_buffer + net::mutable_buffer operator*() const { BOOST_THROW_EXCEPTION(std::logic_error{ @@ -119,11 +119,11 @@ private: void next(C const&) { - if(boost::asio::buffer_size( + if(net::buffer_size( detail::get(*bn_)) != 0) { it_.template emplace( - boost::asio::buffer_sequence_begin( + net::buffer_sequence_begin( detail::get(*bn_))); return; } @@ -142,11 +142,11 @@ private: void prev(C const&) { - if(boost::asio::buffer_size( + if(net::buffer_size( detail::get(*bn_)) != 0) { it_.template emplace( - boost::asio::buffer_sequence_end( + net::buffer_sequence_end( detail::get(*bn_))); return; } @@ -158,7 +158,7 @@ private: { auto constexpr I = 0; it_.template emplace( - boost::asio::buffer_sequence_end( + net::buffer_sequence_end( detail::get(*bn_))); } @@ -205,7 +205,7 @@ private: operator()(mp11::mp_size_t) { auto& it = self.it_.template get(); - if (++it == boost::asio::buffer_sequence_end( + if (++it == net::buffer_sequence_end( detail::get(*self.bn_))) self.next(C()); } @@ -227,7 +227,7 @@ private: if(it_.index() == I+1) { if(it_.template get() != - boost::asio::buffer_sequence_begin( + net::buffer_sequence_begin( detail::get(*bn_))) { --it_.template get(); @@ -243,7 +243,7 @@ private: { auto constexpr I = 0; if(it_.template get() != - boost::asio::buffer_sequence_begin( + net::buffer_sequence_begin( detail::get(*bn_))) { --it_.template get(); diff --git a/include/boost/beast/core/impl/buffers_prefix.ipp b/include/boost/beast/core/impl/buffers_prefix.ipp index c595455d..051547a4 100644 --- a/include/boost/beast/core/impl/buffers_prefix.ipp +++ b/include/boost/beast/core/impl/buffers_prefix.ipp @@ -23,18 +23,18 @@ namespace beast { namespace detail { inline -boost::asio::const_buffer +net::const_buffer buffers_prefix(std::size_t size, - boost::asio::const_buffer buffer) + net::const_buffer buffer) { return {buffer.data(), (std::min)(size, buffer.size())}; } inline -boost::asio::mutable_buffer +net::mutable_buffer buffers_prefix(std::size_t size, - boost::asio::mutable_buffer buffer) + net::mutable_buffer buffer) { return {buffer.data(), (std::min)(size, buffer.size())}; @@ -55,9 +55,9 @@ public: using value_type = typename std::conditional< boost::is_convertible::value_type, - boost::asio::mutable_buffer>::value, - boost::asio::mutable_buffer, - boost::asio::const_buffer>::type; + net::mutable_buffer>::value, + net::mutable_buffer, + net::const_buffer>::type; using pointer = value_type const*; using reference = value_type; using difference_type = std::ptrdiff_t; @@ -107,7 +107,7 @@ public: const_iterator& operator++() { - remain_ -= boost::asio::buffer_size(*it_++); + remain_ -= net::buffer_size(*it_++); return *this; } @@ -115,14 +115,14 @@ public: operator++(int) { auto temp = *this; - remain_ -= boost::asio::buffer_size(*it_++); + remain_ -= net::buffer_size(*it_++); return temp; } const_iterator& operator--() { - remain_ += boost::asio::buffer_size(*--it_); + remain_ += net::buffer_size(*--it_); return *this; } @@ -130,7 +130,7 @@ public: operator--(int) { auto temp = *this; - remain_ += boost::asio::buffer_size(*--it_); + remain_ += net::buffer_size(*--it_); return temp; } @@ -147,7 +147,7 @@ private: std::false_type) : b_(&b) , remain_(b_->size_) - , it_(boost::asio::buffer_sequence_begin(b_->bs_)) + , it_(net::buffer_sequence_begin(b_->bs_)) { } }; @@ -161,12 +161,12 @@ setup(std::size_t size) { size_ = 0; remain_ = 0; - end_ = boost::asio::buffer_sequence_begin(bs_); + end_ = net::buffer_sequence_begin(bs_); auto const last = bs_.end(); while(end_ != last) { auto const len = - boost::asio::buffer_size(*end_++); + net::buffer_size(*end_++); if(len >= size) { size_ += size; @@ -183,7 +183,7 @@ buffers_prefix_view:: buffers_prefix_view(buffers_prefix_view&& other) : buffers_prefix_view(std::move(other), std::distance( - boost::asio::buffer_sequence_begin(other.bs_), + net::buffer_sequence_begin(other.bs_), other.end_)) { } @@ -193,7 +193,7 @@ buffers_prefix_view:: buffers_prefix_view(buffers_prefix_view const& other) : buffers_prefix_view(other, std::distance( - boost::asio::buffer_sequence_begin(other.bs_), + net::buffer_sequence_begin(other.bs_), other.end_)) { } @@ -205,13 +205,13 @@ operator=(buffers_prefix_view&& other) -> buffers_prefix_view& { auto const dist = std::distance( - boost::asio::buffer_sequence_begin(other.bs_), + net::buffer_sequence_begin(other.bs_), other.end_); bs_ = std::move(other.bs_); size_ = other.size_; remain_ = other.remain_; end_ = std::next( - boost::asio::buffer_sequence_begin(bs_), + net::buffer_sequence_begin(bs_), dist); return *this; } @@ -223,13 +223,13 @@ operator=(buffers_prefix_view const& other) -> buffers_prefix_view& { auto const dist = std::distance( - boost::asio::buffer_sequence_begin(other.bs_), + net::buffer_sequence_begin(other.bs_), other.end_); bs_ = other.bs_; size_ = other.size_; remain_ = other.remain_; end_ = std::next( - boost::asio::buffer_sequence_begin(bs_), + net::buffer_sequence_begin(bs_), dist); return *this; } diff --git a/include/boost/beast/core/impl/buffers_suffix.ipp b/include/boost/beast/core/impl/buffers_suffix.ipp index 62b5f463..2d06afe3 100644 --- a/include/boost/beast/core/impl/buffers_suffix.ipp +++ b/include/boost/beast/core/impl/buffers_suffix.ipp @@ -36,9 +36,9 @@ public: using value_type = typename std::conditional< boost::is_convertible::value_type, - boost::asio::mutable_buffer>::value, - boost::asio::mutable_buffer, - boost::asio::const_buffer>::type; + net::mutable_buffer>::value, + net::mutable_buffer, + net::const_buffer>::type; using pointer = value_type const*; using reference = value_type; using difference_type = std::ptrdiff_t; @@ -58,11 +58,11 @@ public: (b_ == nullptr) ? ( other.b_ == nullptr || - other.it_ == boost::asio::buffer_sequence_end(other.b_->bs_) + other.it_ == net::buffer_sequence_end(other.b_->bs_) ):( (other.b_ == nullptr) ? ( - it_ == boost::asio::buffer_sequence_end(b_->bs_) + it_ == net::buffer_sequence_end(b_->bs_) ): ( b_ == other.b_ && it_ == other.it_ @@ -131,7 +131,7 @@ private: template buffers_suffix:: buffers_suffix() - : begin_(boost::asio::buffer_sequence_begin(bs_)) + : begin_(net::buffer_sequence_begin(bs_)) { } @@ -140,7 +140,7 @@ buffers_suffix:: buffers_suffix(buffers_suffix&& other) : buffers_suffix(std::move(other), std::distance( - boost::asio::buffer_sequence_begin( + net::buffer_sequence_begin( other.bs_), other.begin_)) { } @@ -150,7 +150,7 @@ buffers_suffix:: buffers_suffix(buffers_suffix const& other) : buffers_suffix(other, std::distance( - boost::asio::buffer_sequence_begin( + net::buffer_sequence_begin( other.bs_), other.begin_)) { } @@ -159,11 +159,11 @@ template buffers_suffix:: buffers_suffix(Buffers const& bs) : bs_(bs) - , begin_(boost::asio::buffer_sequence_begin(bs_)) + , begin_(net::buffer_sequence_begin(bs_)) { static_assert( - boost::asio::is_const_buffer_sequence::value|| - boost::asio::is_mutable_buffer_sequence::value, + net::is_const_buffer_sequence::value|| + net::is_mutable_buffer_sequence::value, "BufferSequence requirements not met"); } @@ -172,7 +172,7 @@ template buffers_suffix:: buffers_suffix(boost::in_place_init_t, Args&&... args) : bs_(std::forward(args)...) - , begin_(boost::asio::buffer_sequence_begin(bs_)) + , begin_(net::buffer_sequence_begin(bs_)) { static_assert(sizeof...(Args) > 0, "Missing constructor arguments"); @@ -188,11 +188,11 @@ operator=(buffers_suffix&& other) -> buffers_suffix& { auto const dist = std::distance( - boost::asio::buffer_sequence_begin(other.bs_), + net::buffer_sequence_begin(other.bs_), other.begin_); bs_ = std::move(other.bs_); begin_ = std::next( - boost::asio::buffer_sequence_begin(bs_), + net::buffer_sequence_begin(bs_), dist); skip_ = other.skip_; return *this; @@ -205,11 +205,11 @@ operator=(buffers_suffix const& other) -> buffers_suffix& { auto const dist = std::distance( - boost::asio::buffer_sequence_begin(other.bs_), + net::buffer_sequence_begin(other.bs_), other.begin_); bs_ = other.bs_; begin_ = std::next( - boost::asio::buffer_sequence_begin(bs_), dist); + net::buffer_sequence_begin(bs_), dist); skip_ = other.skip_; return *this; } @@ -232,7 +232,7 @@ end() const -> const_iterator { return const_iterator{*this, - boost::asio::buffer_sequence_end(bs_)}; + net::buffer_sequence_end(bs_)}; } template @@ -240,9 +240,9 @@ void buffers_suffix:: consume(std::size_t amount) { - using boost::asio::buffer_size; + using net::buffer_size; auto const end = - boost::asio::buffer_sequence_end(bs_); + net::buffer_sequence_end(bs_); for(;amount > 0 && begin_ != end; ++begin_) { auto const len = diff --git a/include/boost/beast/core/impl/flat_buffer.ipp b/include/boost/beast/core/impl/flat_buffer.ipp index 252638d3..e2672871 100644 --- a/include/boost/beast/core/impl/flat_buffer.ipp +++ b/include/boost/beast/core/impl/flat_buffer.ipp @@ -351,7 +351,7 @@ copy_from(DynamicBuffer const& buffer) { if(buffer.size() == 0) return; - commit(boost::asio::buffer_copy( + commit(net::buffer_copy( prepare(buffer.size()), buffer.data())); } diff --git a/include/boost/beast/core/impl/flat_static_buffer.ipp b/include/boost/beast/core/impl/flat_static_buffer.ipp index 65767306..2c291ca8 100644 --- a/include/boost/beast/core/impl/flat_static_buffer.ipp +++ b/include/boost/beast/core/impl/flat_static_buffer.ipp @@ -90,7 +90,7 @@ flat_static_buffer:: flat_static_buffer(flat_static_buffer const& other) : flat_static_buffer_base(buf_, N) { - using boost::asio::buffer_copy; + using net::buffer_copy; this->commit(buffer_copy( this->prepare(other.size()), other.data())); } @@ -101,7 +101,7 @@ flat_static_buffer:: operator=(flat_static_buffer const& other) -> flat_static_buffer& { - using boost::asio::buffer_copy; + using net::buffer_copy; this->consume(this->size()); this->commit(buffer_copy( this->prepare(other.size()), other.data())); diff --git a/include/boost/beast/core/impl/handler_ptr.ipp b/include/boost/beast/core/impl/handler_ptr.ipp index 06bdd81c..70fbd6d8 100644 --- a/include/boost/beast/core/impl/handler_ptr.ipp +++ b/include/boost/beast/core/impl/handler_ptr.ipp @@ -23,9 +23,9 @@ handler_ptr:: clear() { typename beast::detail::allocator_traits< - boost::asio::associated_allocator_t< + net::associated_allocator_t< Handler>>::template rebind_alloc alloc( - boost::asio::get_associated_allocator( + net::get_associated_allocator( handler())); beast::detail::allocator_traits< decltype(alloc)>::destroy(alloc, t_); @@ -65,9 +65,9 @@ handler_ptr(DeducedHandler&& h, Args&&... args) { BOOST_STATIC_ASSERT(! std::is_array::value); typename beast::detail::allocator_traits< - boost::asio::associated_allocator_t< + net::associated_allocator_t< Handler>>::template rebind_alloc alloc{ - boost::asio::get_associated_allocator(h)}; + net::get_associated_allocator(h)}; using A = decltype(alloc); bool destroy = false; auto deleter = [&alloc, &destroy](T* p) diff --git a/include/boost/beast/core/impl/multi_buffer.ipp b/include/boost/beast/core/impl/multi_buffer.ipp index 0454c25d..d1e0214f 100644 --- a/include/boost/beast/core/impl/multi_buffer.ipp +++ b/include/boost/beast/core/impl/multi_buffer.ipp @@ -143,8 +143,8 @@ class basic_multi_buffer::readable_bytes public: using value_type = typename std::conditional< IsMutable, - boost::asio::mutable_buffer, - boost::asio::const_buffer>::type; + net::mutable_buffer, + net::const_buffer>::type; class const_iterator; @@ -881,7 +881,7 @@ copy_from(DynamicBuffer const& buffer) { if(buffer.size() == 0) return; - using boost::asio::buffer_copy; + using net::buffer_copy; commit(buffer_copy( prepare(buffer.size()), buffer.data())); } @@ -1018,7 +1018,7 @@ basic_multi_buffer:: debug_check() const { #ifndef NDEBUG - using boost::asio::buffer_size; + using net::buffer_size; BOOST_ASSERT(buffer_size(data()) == in_size_); if(list_.empty()) { diff --git a/include/boost/beast/core/impl/read_size.ipp b/include/boost/beast/core/impl/read_size.ipp index fa52571e..fd75db04 100644 --- a/include/boost/beast/core/impl/read_size.ipp +++ b/include/boost/beast/core/impl/read_size.ipp @@ -43,7 +43,7 @@ read_size(DynamicBuffer& buffer, std::size_t max_size, std::false_type) { static_assert( - boost::asio::is_dynamic_buffer::value, + net::is_dynamic_buffer::value, "DynamicBuffer requirements not met"); BOOST_ASSERT(max_size >= 1); auto const size = buffer.size(); diff --git a/include/boost/beast/core/impl/static_buffer.ipp b/include/boost/beast/core/impl/static_buffer.ipp index c860fde8..72e6584c 100644 --- a/include/boost/beast/core/impl/static_buffer.ipp +++ b/include/boost/beast/core/impl/static_buffer.ipp @@ -35,7 +35,7 @@ static_buffer_base:: data() const noexcept -> const_buffers_type { - using boost::asio::const_buffer; + using net::const_buffer; const_buffers_type result; if(in_off_ + in_size_ <= capacity_) { @@ -56,7 +56,7 @@ static_buffer_base:: data() noexcept -> mutable_data_type { - using boost::asio::mutable_buffer; + using net::mutable_buffer; mutable_data_type result; if(in_off_ + in_size_ <= capacity_) { @@ -77,7 +77,7 @@ static_buffer_base:: prepare(std::size_t n) -> mutable_buffers_type { - using boost::asio::mutable_buffer; + using net::mutable_buffer; if(n > capacity_ - in_size_) BOOST_THROW_EXCEPTION(std::length_error{ "buffer overflow"}); @@ -145,7 +145,7 @@ static_buffer:: static_buffer(static_buffer const& other) : static_buffer_base(buf_, N) { - using boost::asio::buffer_copy; + using net::buffer_copy; this->commit(buffer_copy( this->prepare(other.size()), other.data())); } @@ -156,7 +156,7 @@ static_buffer:: operator=(static_buffer const& other) -> static_buffer& { - using boost::asio::buffer_copy; + using net::buffer_copy; this->consume(this->size()); this->commit(buffer_copy( this->prepare(other.size()), other.data())); diff --git a/include/boost/beast/core/multi_buffer.hpp b/include/boost/beast/core/multi_buffer.hpp index 5cd85dfe..ad166a4f 100644 --- a/include/boost/beast/core/multi_buffer.hpp +++ b/include/boost/beast/core/multi_buffer.hpp @@ -86,8 +86,8 @@ class basic_multi_buffer using const_iter = typename list_type::const_iterator; using size_type = typename alloc_traits::size_type; - using const_buffer = boost::asio::const_buffer; - using mutable_buffer = boost::asio::mutable_buffer; + using const_buffer = net::const_buffer; + using mutable_buffer = net::mutable_buffer; static_assert(std::is_base_of::iterator_category>::value, diff --git a/include/boost/beast/core/ostream.hpp b/include/boost/beast/core/ostream.hpp index 1196023d..0523c87f 100644 --- a/include/boost/beast/core/ostream.hpp +++ b/include/boost/beast/core/ostream.hpp @@ -49,7 +49,7 @@ detail::buffers_helper #endif buffers(ConstBufferSequence const& b) { - static_assert(boost::asio::is_const_buffer_sequence< + static_assert(net::is_const_buffer_sequence< ConstBufferSequence>::value, "ConstBufferSequence requirements not met"); return detail::buffers_helper< @@ -91,7 +91,7 @@ detail::ostream_helper< ostream(DynamicBuffer& buffer) { static_assert( - boost::asio::is_dynamic_buffer::value, + net::is_dynamic_buffer::value, "DynamicBuffer requirements not met"); return detail::ostream_helper< DynamicBuffer, char, std::char_traits, diff --git a/include/boost/beast/core/static_buffer.hpp b/include/boost/beast/core/static_buffer.hpp index c74be62e..40703b96 100644 --- a/include/boost/beast/core/static_buffer.hpp +++ b/include/boost/beast/core/static_buffer.hpp @@ -64,23 +64,23 @@ class static_buffer_base class mutable_buffer_pair { - boost::asio::mutable_buffer b_[2]; + net::mutable_buffer b_[2]; friend class const_buffer_pair; public: using const_iterator = - boost::asio::mutable_buffer const*; + net::mutable_buffer const*; // workaround for buffers_iterator bug using value_type = - boost::asio::mutable_buffer; + net::mutable_buffer; mutable_buffer_pair() = default; mutable_buffer_pair( mutable_buffer_pair const&) = default; - boost::asio::mutable_buffer& + net::mutable_buffer& operator[](int i) noexcept { BOOST_ASSERT(i >= 0 && i < 2); @@ -105,15 +105,15 @@ class static_buffer_base class const_buffer_pair { - boost::asio::const_buffer b_[2]; + net::const_buffer b_[2]; public: using const_iterator = - boost::asio::const_buffer const*; + net::const_buffer const*; // workaround for buffers_iterator bug using value_type = - boost::asio::const_buffer; + net::const_buffer; const_buffer_pair() = default; const_buffer_pair( @@ -125,7 +125,7 @@ class static_buffer_base { } - boost::asio::const_buffer& + net::const_buffer& operator[](int i) noexcept { BOOST_ASSERT(i >= 0 && i < 2); diff --git a/include/boost/beast/core/type_traits.hpp b/include/boost/beast/core/type_traits.hpp index d400e7f6..befc17f2 100644 --- a/include/boost/beast/core/type_traits.hpp +++ b/include/boost/beast/core/type_traits.hpp @@ -76,7 +76,7 @@ using is_completion_handler = std::integral_constant void maybe_hello(T& t, std::true_type) { - boost::asio::post( + net::post( t.get_executor(), [] { @@ -102,7 +102,7 @@ using is_completion_handler = std::integral_constant struct basic_dynamic_body { static_assert( - boost::asio::is_dynamic_buffer::value, + net::is_dynamic_buffer::value, "DynamicBuffer requirements not met"); /** The type of container used for the body @@ -88,8 +88,8 @@ struct basic_dynamic_body put(ConstBufferSequence const& buffers, error_code& ec) { - using boost::asio::buffer_copy; - using boost::asio::buffer_size; + using net::buffer_copy; + using net::buffer_size; auto const n = buffer_size(buffers); if(body_.size() > body_.max_size() - n) { diff --git a/include/boost/beast/http/basic_file_body.hpp b/include/boost/beast/http/basic_file_body.hpp index 7dd104d4..67a169e1 100644 --- a/include/boost/beast/http/basic_file_body.hpp +++ b/include/boost/beast/http/basic_file_body.hpp @@ -235,7 +235,7 @@ public: // The type of buffer sequence returned by `get`. // using const_buffers_type = - boost::asio::const_buffer; + net::const_buffer; // Constructor. // @@ -492,11 +492,11 @@ put(ConstBufferSequence const& buffers, error_code& ec) // Loop over all the buffers in the sequence, // and write each one to the file. - for(auto it = boost::asio::buffer_sequence_begin(buffers); - it != boost::asio::buffer_sequence_end(buffers); ++it) + for(auto it = net::buffer_sequence_begin(buffers); + it != net::buffer_sequence_end(buffers); ++it) { // Write this buffer to the file - boost::asio::const_buffer buffer = *it; + net::const_buffer buffer = *it; nwritten += body_.file_.write( buffer.data(), buffer.size(), ec); if(ec) diff --git a/include/boost/beast/http/basic_parser.hpp b/include/boost/beast/http/basic_parser.hpp index dfa1965c..cf17a90f 100644 --- a/include/boost/beast/http/basic_parser.hpp +++ b/include/boost/beast/http/basic_parser.hpp @@ -526,7 +526,7 @@ public: #if ! BOOST_BEAST_DOXYGEN std::size_t - put(boost::asio::const_buffer const& buffer, + put(net::const_buffer const& buffer, error_code& ec); #endif @@ -540,7 +540,7 @@ public: This is typically called when a read from the underlying stream object sets the error code to - `boost::asio::error::eof`. + `net::error::eof`. @note Only valid after parsing a complete header. diff --git a/include/boost/beast/http/buffer_body.hpp b/include/boost/beast/http/buffer_body.hpp index d6dba566..8d9448c1 100644 --- a/include/boost/beast/http/buffer_body.hpp +++ b/include/boost/beast/http/buffer_body.hpp @@ -121,15 +121,15 @@ struct buffer_body put(ConstBufferSequence const& buffers, error_code& ec) { - using boost::asio::buffer_size; - using boost::asio::buffer_copy; + using net::buffer_size; + using net::buffer_copy; if(! body_.data) { ec = error::need_buffer; return 0; } auto const bytes_transferred = - buffer_copy(boost::asio::buffer( + buffer_copy(net::buffer( body_.data, body_.size), buffers); body_.data = static_cast( body_.data) + bytes_transferred; @@ -163,7 +163,7 @@ struct buffer_body public: using const_buffers_type = - boost::asio::const_buffer; + net::const_buffer; template explicit diff --git a/include/boost/beast/http/chunk_encode.hpp b/include/boost/beast/http/chunk_encode.hpp index c782b503..168b83fe 100644 --- a/include/boost/beast/http/chunk_encode.hpp +++ b/include/boost/beast/http/chunk_encode.hpp @@ -32,7 +32,7 @@ namespace http { stream algorithm as the buffer sequence: @code // writes "\r\n" - boost::asio::write(stream, chunk_crlf{}); + net::write(stream, chunk_crlf{}); @endcode @see https://tools.ietf.org/html/rfc7230#section-4.1 @@ -97,7 +97,7 @@ struct chunk_crlf stream algorithm as the buffer sequence: @code // writes "400;x\r\n" - boost::asio::write(stream, chunk_header{1024, "x"}); + net::write(stream, chunk_header{1024, "x"}); @endcode @see https://tools.ietf.org/html/rfc7230#section-4.1 @@ -106,7 +106,7 @@ class chunk_header { using view_type = buffers_cat_view< detail::chunk_size, // chunk-size - boost::asio::const_buffer, // chunk-extensions + net::const_buffer, // chunk-extensions chunk_crlf>; // CRLF std::shared_ptr< @@ -285,7 +285,7 @@ class chunk_body { using view_type = buffers_cat_view< detail::chunk_size, // chunk-size - boost::asio::const_buffer, // chunk-extensions + net::const_buffer, // chunk-extensions chunk_crlf, // CRLF ConstBufferSequence, // chunk-body chunk_crlf>; // CRLF @@ -459,7 +459,7 @@ class chunk_last { static_assert( is_fields::value || - boost::asio::is_const_buffer_sequence::value, + net::is_const_buffer_sequence::value, "Trailer requirements not met"); using buffers_type = typename diff --git a/include/boost/beast/http/detail/chunk_encode.hpp b/include/boost/beast/http/detail/chunk_encode.hpp index 87ac9ec4..cdf7e1e8 100644 --- a/include/boost/beast/http/detail/chunk_encode.hpp +++ b/include/boost/beast/http/detail/chunk_encode.hpp @@ -26,7 +26,7 @@ namespace detail { struct chunk_extensions { virtual ~chunk_extensions() = default; - virtual boost::asio::const_buffer str() = 0; + virtual net::const_buffer str() = 0; }; template @@ -44,7 +44,7 @@ struct chunk_extensions_impl : chunk_extensions { } - boost::asio::const_buffer + net::const_buffer str() override { auto const s = ext_.str(); @@ -88,7 +88,7 @@ class chunk_size struct sequence { - boost::asio::const_buffer b; + net::const_buffer b; char data[1 + 2 * sizeof(std::size_t)]; explicit @@ -104,7 +104,7 @@ class chunk_size std::shared_ptr sp_; public: - using value_type = boost::asio::const_buffer; + using value_type = net::const_buffer; using const_iterator = value_type const*; @@ -136,7 +136,7 @@ public: /// Returns a buffer sequence holding a CRLF for chunk encoding inline -boost::asio::const_buffer +net::const_buffer chunk_crlf() { return {"\r\n", 2}; @@ -144,7 +144,7 @@ chunk_crlf() /// Returns a buffer sequence holding a final chunk header inline -boost::asio::const_buffer +net::const_buffer chunk_last() { return {"0\r\n", 3}; @@ -163,7 +163,7 @@ struct chunk_crlf_iter_type value_type() = default; operator - boost::asio::const_buffer() const + net::const_buffer() const { return {s, sizeof(s)}; } @@ -190,7 +190,7 @@ struct chunk_size0_iter_type value_type() = default; operator - boost::asio::const_buffer() const + net::const_buffer() const { return {s, sizeof(s)}; } diff --git a/include/boost/beast/http/empty_body.hpp b/include/boost/beast/http/empty_body.hpp index c5dd9c55..ec43e92c 100644 --- a/include/boost/beast/http/empty_body.hpp +++ b/include/boost/beast/http/empty_body.hpp @@ -100,7 +100,7 @@ struct empty_body struct writer { using const_buffers_type = - boost::asio::const_buffer; + net::const_buffer; template explicit diff --git a/include/boost/beast/http/error.hpp b/include/boost/beast/http/error.hpp index b3d9fb11..0164cc89 100644 --- a/include/boost/beast/http/error.hpp +++ b/include/boost/beast/http/error.hpp @@ -23,7 +23,7 @@ enum class error /** The end of the stream was reached. This error is returned when attempting to read HTTP data, - and the stream returns the error `boost::asio::error::eof` + and the stream returns the error `net::error::eof` before any octets corresponding to a new HTTP message have been received. */ diff --git a/include/boost/beast/http/fields.hpp b/include/boost/beast/http/fields.hpp index caa03d1c..72a8f0e3 100644 --- a/include/boost/beast/http/fields.hpp +++ b/include/boost/beast/http/fields.hpp @@ -85,7 +85,7 @@ public: char* data() const; - boost::asio::const_buffer + net::const_buffer buffer() const; protected: diff --git a/include/boost/beast/http/impl/basic_parser.ipp b/include/boost/beast/http/impl/basic_parser.ipp index 7a460928..93bf3d40 100644 --- a/include/boost/beast/http/impl/basic_parser.ipp +++ b/include/boost/beast/http/impl/basic_parser.ipp @@ -91,13 +91,13 @@ basic_parser:: put(ConstBufferSequence const& buffers, error_code& ec) { - static_assert(boost::asio::is_const_buffer_sequence< + static_assert(net::is_const_buffer_sequence< ConstBufferSequence>::value, "ConstBufferSequence requirements not met"); - using boost::asio::buffer_copy; - using boost::asio::buffer_size; - auto const p = boost::asio::buffer_sequence_begin(buffers); - auto const last = boost::asio::buffer_sequence_end(buffers); + using net::buffer_copy; + using net::buffer_size; + auto const p = net::buffer_sequence_begin(buffers); + auto const last = net::buffer_sequence_end(buffers); if(p == last) { ec.assign(0, ec.category()); @@ -106,7 +106,7 @@ put(ConstBufferSequence const& buffers, if(std::next(p) == last) { // single buffer - return put(boost::asio::const_buffer(*p), ec); + return put(net::const_buffer(*p), ec); } auto const size = buffer_size(buffers); if(size <= max_stack_buffer) @@ -118,20 +118,20 @@ put(ConstBufferSequence const& buffers, buf_len_ = size; } // flatten - buffer_copy(boost::asio::buffer( + buffer_copy(net::buffer( buf_.get(), buf_len_), buffers); - return put(boost::asio::const_buffer{ + return put(net::const_buffer{ buf_.get(), buf_len_}, ec); } template std::size_t basic_parser:: -put(boost::asio::const_buffer const& buffer, +put(net::const_buffer const& buffer, error_code& ec) { BOOST_ASSERT(state_ != state::complete); - using boost::asio::buffer_size; + using net::buffer_size; auto p = static_cast(buffer.data()); auto n = buffer.size(); auto const p0 = p; @@ -304,10 +304,10 @@ put_from_stack(std::size_t size, error_code& ec) { char buf[max_stack_buffer]; - using boost::asio::buffer; - using boost::asio::buffer_copy; + using net::buffer; + using net::buffer_copy; buffer_copy(buffer(buf, sizeof(buf)), buffers); - return put(boost::asio::const_buffer{ + return put(net::const_buffer{ buf, size}, ec); } diff --git a/include/boost/beast/http/impl/chunk_encode.ipp b/include/boost/beast/http/impl/chunk_encode.ipp index 51296041..b8cf86d7 100644 --- a/include/boost/beast/http/impl/chunk_encode.ipp +++ b/include/boost/beast/http/impl/chunk_encode.ipp @@ -24,7 +24,7 @@ chunk_header:: chunk_header(std::size_t size) : view_( size, - boost::asio::const_buffer{nullptr, 0}, + net::const_buffer{nullptr, 0}, chunk_crlf{}) { BOOST_ASSERT(size > 0); @@ -37,7 +37,7 @@ chunk_header( string_view extensions) : view_( size, - boost::asio::const_buffer{ + net::const_buffer{ extensions.data(), extensions.size()}, chunk_crlf{}) { @@ -89,8 +89,8 @@ template chunk_body:: chunk_body(ConstBufferSequence const& buffers) : view_( - boost::asio::buffer_size(buffers), - boost::asio::const_buffer{nullptr, 0}, + net::buffer_size(buffers), + net::const_buffer{nullptr, 0}, chunk_crlf{}, buffers, chunk_crlf{}) @@ -103,8 +103,8 @@ chunk_body( ConstBufferSequence const& buffers, string_view extensions) : view_( - boost::asio::buffer_size(buffers), - boost::asio::const_buffer{ + net::buffer_size(buffers), + net::const_buffer{ extensions.data(), extensions.size()}, chunk_crlf{}, buffers, @@ -122,7 +122,7 @@ chunk_body( typename std::decay::type>>( std::forward(extensions))) , view_( - boost::asio::buffer_size(buffers), + net::buffer_size(buffers), exts_->str(), chunk_crlf{}, buffers, @@ -141,7 +141,7 @@ chunk_body( typename std::decay::type>>(allocator, std::forward(extensions))) , view_( - boost::asio::buffer_size(buffers), + net::buffer_size(buffers), exts_->str(), chunk_crlf{}, buffers, diff --git a/include/boost/beast/http/impl/fields.ipp b/include/boost/beast/http/impl/fields.ipp index f34a8e74..6b8182d8 100644 --- a/include/boost/beast/http/impl/fields.ipp +++ b/include/boost/beast/http/impl/fields.ipp @@ -44,7 +44,7 @@ public: { iter_type it_; - using value_type = boost::asio::const_buffer; + using value_type = net::const_buffer; using pointer = value_type const*; using reference = value_type const; using difference_type = std::ptrdiff_t; @@ -144,9 +144,9 @@ public: }; using view_type = buffers_cat_view< - boost::asio::const_buffer, - boost::asio::const_buffer, - boost::asio::const_buffer, + net::const_buffer, + net::const_buffer, + net::const_buffer, field_range, chunk_crlf>; @@ -179,9 +179,9 @@ writer(basic_fields const& f) : f_(f) { view_.emplace( - boost::asio::const_buffer{nullptr, 0}, - boost::asio::const_buffer{nullptr, 0}, - boost::asio::const_buffer{nullptr, 0}, + net::const_buffer{nullptr, 0}, + net::const_buffer{nullptr, 0}, + net::const_buffer{nullptr, 0}, field_range(f_.list_.begin(), f_.list_.end()), chunk_crlf()); } @@ -219,11 +219,11 @@ writer(basic_fields const& f, buf_[10]= '\n'; view_.emplace( - boost::asio::const_buffer{sv.data(), sv.size()}, - boost::asio::const_buffer{ + net::const_buffer{sv.data(), sv.size()}, + net::const_buffer{ f_.target_or_reason_.data(), f_.target_or_reason_.size()}, - boost::asio::const_buffer{buf_, 11}, + net::const_buffer{buf_, 11}, field_range(f_.list_.begin(), f_.list_.end()), chunk_crlf()); } @@ -261,9 +261,9 @@ writer(basic_fields const& f, sv = obsolete_reason(static_cast(code)); view_.emplace( - boost::asio::const_buffer{buf_, 13}, - boost::asio::const_buffer{sv.data(), sv.size()}, - boost::asio::const_buffer{"\r\n", 2}, + net::const_buffer{buf_, 13}, + net::const_buffer{sv.data(), sv.size()}, + net::const_buffer{"\r\n", 2}, field_range(f_.list_.begin(), f_.list_.end()), chunk_crlf{}); } @@ -282,12 +282,12 @@ data() const } template -boost::asio::const_buffer +net::const_buffer basic_fields:: value_type:: buffer() const { - return boost::asio::const_buffer{data(), + return net::const_buffer{data(), static_cast(off_) + len_ + 2}; } diff --git a/include/boost/beast/http/impl/file_body_win32.ipp b/include/boost/beast/http/impl/file_body_win32.ipp index 346d39af..279e01a8 100644 --- a/include/boost/beast/http/impl/file_body_win32.ipp +++ b/include/boost/beast/http/impl/file_body_win32.ipp @@ -64,7 +64,7 @@ struct basic_file_body friend std::size_t write_some( - boost::asio::basic_stream_socket& sock, + net::basic_stream_socket& sock, serializer, Fields>& sr, error_code& ec); @@ -113,7 +113,7 @@ struct basic_file_body friend std::size_t write_some( - boost::asio::basic_stream_socket& sock, + net::basic_stream_socket& sock, serializer, Fields>& sr, error_code& ec); @@ -124,7 +124,7 @@ struct basic_file_body public: using const_buffers_type = - boost::asio::const_buffer; + net::const_buffer; template writer(header&, value_type& b) @@ -338,9 +338,9 @@ template< bool isRequest, class Fields> class write_some_win32_op { - boost::asio::basic_stream_socket& sock_; - boost::asio::executor_work_guard&>().get_executor())> wg_; + net::basic_stream_socket& sock_; + net::executor_work_guard&>().get_executor())> wg_; serializer, Fields>& sr_; std::size_t bytes_transferred_ = 0; @@ -354,7 +354,7 @@ public: template write_some_win32_op( DeducedHandler&& h, - boost::asio::basic_stream_socket& s, + net::basic_stream_socket& s, serializer,Fields>& sr) : sock_(s) @@ -365,22 +365,22 @@ public: } using allocator_type = - boost::asio::associated_allocator_t; + net::associated_allocator_t; allocator_type get_allocator() const noexcept { - return (boost::asio::get_associated_allocator)(h_); + return (net::get_associated_allocator)(h_); } using executor_type = - boost::asio::associated_executor_t&>().get_executor())>; + net::associated_executor_t&>().get_executor())>; executor_type get_executor() const noexcept { - return (boost::asio::get_associated_executor)( + return (net::get_associated_executor)( h_, sock_.get_executor()); } @@ -395,7 +395,7 @@ public: friend bool asio_handler_is_continuation(write_some_win32_op* op) { - using boost::asio::asio_handler_is_continuation; + using net::asio_handler_is_continuation; return asio_handler_is_continuation( std::addressof(op->h_)); } @@ -404,7 +404,7 @@ public: friend void asio_handler_invoke(Function&& f, write_some_win32_op* op) { - using boost::asio::asio_handler_invoke; + using net::asio_handler_invoke; asio_handler_invoke(f, std::addressof(op->h_)); } }; @@ -435,7 +435,7 @@ operator()() (std::min)( (std::min)(w.body_.last_ - w.pos_, sr_.limit()), (std::numeric_limits::max)())); - boost::asio::windows::overlapped_ptr overlapped{ + net::windows::overlapped_ptr overlapped{ sock_.get_executor().context(), std::move(*this)}; // Note that we have moved *this, so we cannot access // the handler since it is now moved-from. We can still @@ -503,7 +503,7 @@ operator()( template std::size_t write_some( - boost::asio::basic_stream_socket& sock, + net::basic_stream_socket& sock, serializer, Fields>& sr, error_code& ec) @@ -573,7 +573,7 @@ template< BOOST_ASIO_INITFN_RESULT_TYPE( WriteHandler, void(error_code, std::size_t)) async_write_some( - boost::asio::basic_stream_socket& sock, + net::basic_stream_socket& sock, serializer, Fields>& sr, WriteHandler&& handler) diff --git a/include/boost/beast/http/impl/read.ipp b/include/boost/beast/http/impl/read.ipp index aeccced0..78773af1 100644 --- a/include/boost/beast/http/impl/read.ipp +++ b/include/boost/beast/http/impl/read.ipp @@ -43,10 +43,10 @@ namespace detail { template class read_some_op - : public boost::asio::coroutine + : public net::coroutine { Stream& s_; - boost::asio::executor_work_guard().get_executor())> wg_; DynamicBuffer& b_; basic_parser& p_; @@ -70,21 +70,21 @@ public: } using allocator_type = - boost::asio::associated_allocator_t; + net::associated_allocator_t; allocator_type get_allocator() const noexcept { - return (boost::asio::get_associated_allocator)(h_); + return (net::get_associated_allocator)(h_); } - using executor_type = boost::asio::associated_executor_t< + using executor_type = net::associated_executor_t< Handler, decltype(std::declval().get_executor())>; executor_type get_executor() const noexcept { - return (boost::asio::get_associated_executor)( + return (net::get_associated_executor)( h_, s_.get_executor()); } @@ -97,7 +97,7 @@ public: friend bool asio_handler_is_continuation(read_some_op* op) { - using boost::asio::asio_handler_is_continuation; + using net::asio_handler_is_continuation; return op->cont_ ? true : asio_handler_is_continuation( std::addressof(op->h_)); @@ -107,7 +107,7 @@ public: friend void asio_handler_invoke(Function&& f, read_some_op* op) { - using boost::asio::asio_handler_invoke; + using net::asio_handler_invoke; asio_handler_invoke(f, std::addressof(op->h_)); } }; @@ -155,7 +155,7 @@ operator()( goto upcall; s_.async_read_some(*mb, std::move(*this)); } - if(ec == boost::asio::error::eof) + if(ec == net::error::eof) { BOOST_ASSERT(bytes_transferred == 0); if(p_.got_some()) @@ -180,7 +180,7 @@ operator()( if(! cont_) { BOOST_ASIO_CORO_YIELD - boost::asio::post( + net::post( s_.get_executor(), beast::bind_front_handler(std::move(*this), ec, bytes_transferred_)); @@ -217,10 +217,10 @@ template class read_op - : public boost::asio::coroutine + : public net::coroutine { Stream& s_; - boost::asio::executor_work_guard().get_executor())> wg_; DynamicBuffer& b_; basic_parser& p_; @@ -245,21 +245,21 @@ public: } using allocator_type = - boost::asio::associated_allocator_t; + net::associated_allocator_t; allocator_type get_allocator() const noexcept { - return (boost::asio::get_associated_allocator)(h_); + return (net::get_associated_allocator)(h_); } - using executor_type = boost::asio::associated_executor_t< + using executor_type = net::associated_executor_t< Handler, decltype(std::declval().get_executor())>; executor_type get_executor() const noexcept { - return (boost::asio::get_associated_executor)( + return (net::get_associated_executor)( h_, s_.get_executor()); } @@ -272,7 +272,7 @@ public: friend bool asio_handler_is_continuation(read_op* op) { - using boost::asio::asio_handler_is_continuation; + using net::asio_handler_is_continuation; return op->cont_ ? true : asio_handler_is_continuation( std::addressof(op->h_)); @@ -282,7 +282,7 @@ public: friend void asio_handler_invoke(Function&& f, read_op* op) { - using boost::asio::asio_handler_invoke; + using net::asio_handler_invoke; asio_handler_invoke(f, std::addressof(op->h_)); } }; @@ -304,7 +304,7 @@ operator()( if(Condition{}(p_)) { BOOST_ASIO_CORO_YIELD - boost::asio::post(s_.get_executor(), + net::post(s_.get_executor(), beast::bind_front_handler(std::move(*this), ec)); goto upcall; } @@ -330,7 +330,7 @@ template class read_msg_op - : public boost::asio::coroutine + : public net::coroutine { using parser_type = parser; @@ -341,7 +341,7 @@ class read_msg_op struct data { Stream& s; - boost::asio::executor_work_guard().get_executor())> wg; DynamicBuffer& b; message_type& m; @@ -375,21 +375,21 @@ public: } using allocator_type = - boost::asio::associated_allocator_t; + net::associated_allocator_t; allocator_type get_allocator() const noexcept { - return (boost::asio::get_associated_allocator)(d_.handler()); + return (net::get_associated_allocator)(d_.handler()); } - using executor_type = boost::asio::associated_executor_t< + using executor_type = net::associated_executor_t< Handler, decltype(std::declval().get_executor())>; executor_type get_executor() const noexcept { - return (boost::asio::get_associated_executor)( + return (net::get_associated_executor)( d_.handler(), d_->s.get_executor()); } @@ -402,7 +402,7 @@ public: friend bool asio_handler_is_continuation(read_msg_op* op) { - using boost::asio::asio_handler_is_continuation; + using net::asio_handler_is_continuation; return op->d_->cont ? true : asio_handler_is_continuation( std::addressof(op->d_.handler())); @@ -412,7 +412,7 @@ public: friend void asio_handler_invoke(Function&& f, read_msg_op* op) { - using boost::asio::asio_handler_invoke; + using net::asio_handler_invoke; asio_handler_invoke(f, std::addressof(op->d_.handler())); } }; @@ -473,7 +473,7 @@ read_some( static_assert(is_sync_read_stream::value, "SyncReadStream requirements not met"); static_assert( - boost::asio::is_dynamic_buffer::value, + net::is_dynamic_buffer::value, "DynamicBuffer requirements not met"); BOOST_ASSERT(! parser.is_done()); error_code ec; @@ -498,7 +498,7 @@ read_some( static_assert(is_sync_read_stream::value, "SyncReadStream requirements not met"); static_assert( - boost::asio::is_dynamic_buffer::value, + net::is_dynamic_buffer::value, "DynamicBuffer requirements not met"); BOOST_ASSERT(! parser.is_done()); std::size_t bytes_transferred = 0; @@ -529,7 +529,7 @@ read_some( if(ec) break; auto const n = stream.read_some(*mb, ec); - if(ec == boost::asio::error::eof) + if(ec == net::error::eof) { BOOST_ASSERT(n == 0); if(parser.got_some()) @@ -567,7 +567,7 @@ async_read_some( static_assert(is_async_read_stream::value, "AsyncReadStream requirements not met"); static_assert( - boost::asio::is_dynamic_buffer::value, + net::is_dynamic_buffer::value, "DynamicBuffer requirements not met"); BOOST_ASSERT(! parser.is_done()); BOOST_BEAST_HANDLER_INIT( @@ -595,7 +595,7 @@ read_header( static_assert(is_sync_read_stream::value, "SyncReadStream requirements not met"); static_assert( - boost::asio::is_dynamic_buffer::value, + net::is_dynamic_buffer::value, "DynamicBuffer requirements not met"); error_code ec; auto const bytes_transferred = @@ -619,7 +619,7 @@ read_header( static_assert(is_sync_read_stream::value, "SyncReadStream requirements not met"); static_assert( - boost::asio::is_dynamic_buffer::value, + net::is_dynamic_buffer::value, "DynamicBuffer requirements not met"); parser.eager(false); if(parser.is_header_done()) @@ -655,7 +655,7 @@ async_read_header( static_assert(is_async_read_stream::value, "AsyncReadStream requirements not met"); static_assert( - boost::asio::is_dynamic_buffer::value, + net::is_dynamic_buffer::value, "DynamicBuffer requirements not met"); parser.eager(false); BOOST_BEAST_HANDLER_INIT( @@ -683,7 +683,7 @@ read( static_assert(is_sync_read_stream::value, "SyncReadStream requirements not met"); static_assert( - boost::asio::is_dynamic_buffer::value, + net::is_dynamic_buffer::value, "DynamicBuffer requirements not met"); error_code ec; auto const bytes_transferred = @@ -707,7 +707,7 @@ read( static_assert(is_sync_read_stream::value, "SyncReadStream requirements not met"); static_assert( - boost::asio::is_dynamic_buffer::value, + net::is_dynamic_buffer::value, "DynamicBuffer requirements not met"); parser.eager(true); if(parser.is_done()) @@ -743,7 +743,7 @@ async_read( static_assert(is_async_read_stream::value, "AsyncReadStream requirements not met"); static_assert( - boost::asio::is_dynamic_buffer::value, + net::is_dynamic_buffer::value, "DynamicBuffer requirements not met"); parser.eager(true); BOOST_BEAST_HANDLER_INIT( @@ -771,7 +771,7 @@ read( static_assert(is_sync_read_stream::value, "SyncReadStream requirements not met"); static_assert( - boost::asio::is_dynamic_buffer::value, + net::is_dynamic_buffer::value, "DynamicBuffer requirements not met"); static_assert(is_body::value, "Body requirements not met"); @@ -799,7 +799,7 @@ read( static_assert(is_sync_read_stream::value, "SyncReadStream requirements not met"); static_assert( - boost::asio::is_dynamic_buffer::value, + net::is_dynamic_buffer::value, "DynamicBuffer requirements not met"); static_assert(is_body::value, "Body requirements not met"); @@ -831,7 +831,7 @@ async_read( static_assert(is_async_read_stream::value, "AsyncReadStream requirements not met"); static_assert( - boost::asio::is_dynamic_buffer::value, + net::is_dynamic_buffer::value, "DynamicBuffer requirements not met"); static_assert(is_body::value, "Body requirements not met"); diff --git a/include/boost/beast/http/impl/serializer.ipp b/include/boost/beast/http/impl/serializer.ipp index b9e7d26b..ccad3d9e 100644 --- a/include/boost/beast/http/impl/serializer.ipp +++ b/include/boost/beast/http/impl/serializer.ipp @@ -70,7 +70,7 @@ void serializer:: next(error_code& ec, Visit&& visit) { - using boost::asio::buffer_size; + using net::buffer_size; switch(s_) { case do_construct: @@ -166,12 +166,12 @@ next(error_code& ec, Visit&& visit) boost::in_place_init, fwr_->get(), buffer_size(result->first), - boost::asio::const_buffer{nullptr, 0}, + net::const_buffer{nullptr, 0}, chunk_crlf{}, result->first, chunk_crlf{}, detail::chunk_last(), - boost::asio::const_buffer{nullptr, 0}, + net::const_buffer{nullptr, 0}, chunk_crlf{}); goto go_all_c; } @@ -179,7 +179,7 @@ next(error_code& ec, Visit&& visit) boost::in_place_init, fwr_->get(), buffer_size(result->first), - boost::asio::const_buffer{nullptr, 0}, + net::const_buffer{nullptr, 0}, chunk_crlf{}, result->first, chunk_crlf{}); @@ -218,19 +218,19 @@ next(error_code& ec, Visit&& visit) v_.template emplace<6>( boost::in_place_init, buffer_size(result->first), - boost::asio::const_buffer{nullptr, 0}, + net::const_buffer{nullptr, 0}, chunk_crlf{}, result->first, chunk_crlf{}, detail::chunk_last(), - boost::asio::const_buffer{nullptr, 0}, + net::const_buffer{nullptr, 0}, chunk_crlf{}); goto go_body_final_c; } v_.template emplace<5>( boost::in_place_init, buffer_size(result->first), - boost::asio::const_buffer{nullptr, 0}, + net::const_buffer{nullptr, 0}, chunk_crlf{}, result->first, chunk_crlf{}); @@ -261,7 +261,7 @@ next(error_code& ec, Visit&& visit) v_.template emplace<8>( boost::in_place_init, detail::chunk_last(), - boost::asio::const_buffer{nullptr, 0}, + net::const_buffer{nullptr, 0}, chunk_crlf{}); s_ = do_final_c + 1; BOOST_FALLTHROUGH; @@ -289,7 +289,7 @@ void serializer:: consume(std::size_t n) { - using boost::asio::buffer_size; + using net::buffer_size; switch(s_) { case do_header: diff --git a/include/boost/beast/http/impl/write.ipp b/include/boost/beast/http/impl/write.ipp index 96d64a43..180a029d 100644 --- a/include/boost/beast/http/impl/write.ipp +++ b/include/boost/beast/http/impl/write.ipp @@ -41,7 +41,7 @@ template< class write_some_op { Stream& s_; - boost::asio::executor_work_guard().get_executor())> wg_; serializer& sr_; Handler h_; @@ -86,21 +86,21 @@ public: } using allocator_type = - boost::asio::associated_allocator_t; + net::associated_allocator_t; allocator_type get_allocator() const noexcept { - return (boost::asio::get_associated_allocator)(h_); + return (net::get_associated_allocator)(h_); } - using executor_type = boost::asio::associated_executor_t< + using executor_type = net::associated_executor_t< Handler, decltype(std::declval().get_executor())>; executor_type get_executor() const noexcept { - return (boost::asio::get_associated_executor)( + return (net::get_associated_executor)( h_, s_.get_executor()); } @@ -115,7 +115,7 @@ public: friend bool asio_handler_is_continuation(write_some_op* op) { - using boost::asio::asio_handler_is_continuation; + using net::asio_handler_is_continuation; return asio_handler_is_continuation( std::addressof(op->h_)); } @@ -124,7 +124,7 @@ public: friend void asio_handler_invoke(Function&& f, write_some_op* op) { - using boost::asio::asio_handler_invoke; + using net::asio_handler_invoke; asio_handler_invoke(f, std::addressof(op->h_)); } }; @@ -145,7 +145,7 @@ operator()() if(ec) { BOOST_ASSERT(! f.invoked); - return boost::asio::post( + return net::post( s_.get_executor(), beast::bind_front_handler(std::move(*this), ec, 0)); } @@ -158,7 +158,7 @@ operator()() // What else could it be? BOOST_ASSERT(sr_.is_done()); } - return boost::asio::post( + return net::post( s_.get_executor(), beast::bind_front_handler(std::move(*this), ec, 0)); } @@ -208,10 +208,10 @@ struct serializer_is_done template< class Stream, class Handler, class Predicate, bool isRequest, class Body, class Fields> -class write_op : public boost::asio::coroutine +class write_op : public net::coroutine { Stream& s_; - boost::asio::executor_work_guard().get_executor())> wg_; serializer& sr_; std::size_t bytes_transferred_ = 0; @@ -231,7 +231,7 @@ public: , h_(std::forward(h)) , cont_([&] { - using boost::asio::asio_handler_is_continuation; + using net::asio_handler_is_continuation; return asio_handler_is_continuation( std::addressof(h_)); }()) @@ -239,21 +239,21 @@ public: } using allocator_type = - boost::asio::associated_allocator_t; + net::associated_allocator_t; allocator_type get_allocator() const noexcept { - return (boost::asio::get_associated_allocator)(h_); + return (net::get_associated_allocator)(h_); } - using executor_type = boost::asio::associated_executor_t< + using executor_type = net::associated_executor_t< Handler, decltype(std::declval().get_executor())>; executor_type get_executor() const noexcept { - return (boost::asio::get_associated_executor)( + return (net::get_associated_executor)( h_, s_.get_executor()); } @@ -272,7 +272,7 @@ public: friend void asio_handler_invoke(Function&& f, write_op* op) { - using boost::asio::asio_handler_invoke; + using net::asio_handler_invoke; asio_handler_invoke(f, std::addressof(op->h_)); } }; @@ -292,7 +292,7 @@ operator()( if(Predicate{}(sr_)) { BOOST_ASIO_CORO_YIELD - boost::asio::post( + net::post( s_.get_executor(), std::move(*this)); goto upcall; @@ -323,7 +323,7 @@ class write_msg_op struct data { Stream& s; - boost::asio::executor_work_guard().get_executor())> wg; serializer sr; @@ -358,21 +358,21 @@ public: } using allocator_type = - boost::asio::associated_allocator_t; + net::associated_allocator_t; allocator_type get_allocator() const noexcept { - return (boost::asio::get_associated_allocator)(d_.handler()); + return (net::get_associated_allocator)(d_.handler()); } - using executor_type = boost::asio::associated_executor_t< + using executor_type = net::associated_executor_t< Handler, decltype(std::declval().get_executor())>; executor_type get_executor() const noexcept { - return (boost::asio::get_associated_executor)( + return (net::get_associated_executor)( d_.handler(), d_->s.get_executor()); } @@ -386,7 +386,7 @@ public: friend bool asio_handler_is_continuation(write_msg_op* op) { - using boost::asio::asio_handler_is_continuation; + using net::asio_handler_is_continuation; return asio_handler_is_continuation( std::addressof(op->d_.handler())); } @@ -395,7 +395,7 @@ public: friend void asio_handler_invoke(Function&& f, write_msg_op* op) { - using boost::asio::asio_handler_invoke; + using net::asio_handler_invoke; asio_handler_invoke(f, std::addressof(op->d_.handler())); } }; @@ -471,7 +471,7 @@ public: ConstBufferSequence const& buffers) { invoked = true; - bytes_transferred = boost::asio::write( + bytes_transferred = net::write( stream_, buffers, ec); } }; diff --git a/include/boost/beast/http/parser.hpp b/include/boost/beast/http/parser.hpp index fb7b74f2..3e166a9d 100644 --- a/include/boost/beast/http/parser.hpp +++ b/include/boost/beast/http/parser.hpp @@ -414,7 +414,7 @@ private: string_view body, error_code& ec) { - return rd_.put(boost::asio::buffer( + return rd_.put(net::buffer( body.data(), body.size()), ec); } @@ -437,7 +437,7 @@ private: { if(cb_b_) return cb_b_(remain, body, ec); - return rd_.put(boost::asio::buffer( + return rd_.put(net::buffer( body.data(), body.size()), ec); } diff --git a/include/boost/beast/http/read.hpp b/include/boost/beast/http/read.hpp index a4f0efe4..1d6698f9 100644 --- a/include/boost/beast/http/read.hpp +++ b/include/boost/beast/http/read.hpp @@ -37,7 +37,7 @@ namespace http { end of the message being read. This additional data is stored in the dynamic buffer, which must be retained for subsequent reads. - If the stream returns the error `boost::asio::error::eof` indicating the + If the stream returns the error `net::error::eof` indicating the end of file during a read, the error returned from this function will be: @li @ref error::end_of_stream if no octets were parsed, or @@ -90,7 +90,7 @@ read_some( end of the message being read. This additional data is stored in the dynamic buffer, which must be retained for subsequent reads. - If the stream returns the error `boost::asio::error::eof` indicating the + If the stream returns the error `net::error::eof` indicating the end of file during a read, the error returned from this function will be: @li @ref error::end_of_stream if no octets were parsed, or @@ -151,7 +151,7 @@ read_some( end of the object being parsed. This additional data is stored in the stream buffer, which may be used in subsequent calls. - If the stream returns the error `boost::asio::error::eof` indicating the + If the stream returns the error `net::error::eof` indicating the end of file during a read, the error returned from this function will be: @li @ref error::end_of_stream if no octets were parsed, or @@ -185,7 +185,7 @@ read_some( Regardless of whether the asynchronous operation completes immediately or not, the handler will not be invoked from within this function. Invocation of the handler will be performed in a - manner equivalent to using `boost::asio::io_context::post`. + manner equivalent to using `net::io_context::post`. The completion handler will receive as a parameter the number of octets processed from the dynamic buffer. The octets should @@ -223,7 +223,7 @@ async_read_some( end of the message being read. This additional data is stored in the dynamic buffer, which must be retained for subsequent reads. - If the stream returns the error `boost::asio::error::eof` indicating the + If the stream returns the error `net::error::eof` indicating the end of file during a read, the error returned from this function will be: @li @ref error::end_of_stream if no octets were parsed, or @@ -278,7 +278,7 @@ read_header( end of the message being read. This additional data is stored in the dynamic buffer, which must be retained for subsequent reads. - If the stream returns the error `boost::asio::error::eof` indicating the + If the stream returns the error `net::error::eof` indicating the end of file during a read, the error returned from this function will be: @li @ref error::end_of_stream if no octets were parsed, or @@ -337,7 +337,7 @@ read_header( end of the message being read. This additional data is stored in the dynamic buffer, which must be retained for subsequent reads. - If the stream returns the error `boost::asio::error::eof` indicating the + If the stream returns the error `net::error::eof` indicating the end of file during a read, the error returned from this function will be: @li @ref error::end_of_stream if no octets were parsed, or @@ -371,7 +371,7 @@ read_header( Regardless of whether the asynchronous operation completes immediately or not, the handler will not be invoked from within this function. Invocation of the handler will be performed in a - manner equivalent to using `boost::asio::io_context::post`. + manner equivalent to using `net::io_context::post`. @note The implementation will call @ref basic_parser::eager with the value `false` on the parser passed in. @@ -407,7 +407,7 @@ async_read_header( end of the message being read. This additional data is stored in the dynamic buffer, which must be retained for subsequent reads. - If the stream returns the error `boost::asio::error::eof` indicating the + If the stream returns the error `net::error::eof` indicating the end of file during a read, the error returned from this function will be: @li @ref error::end_of_stream if no octets were parsed, or @@ -462,7 +462,7 @@ read( end of the message being read. This additional data is stored in the dynamic buffer, which must be retained for subsequent reads. - If the stream returns the error `boost::asio::error::eof` indicating the + If the stream returns the error `net::error::eof` indicating the end of file during a read, the error returned from this function will be: @li @ref error::end_of_stream if no octets were parsed, or @@ -521,7 +521,7 @@ read( end of the message being read. This additional data is stored in the dynamic buffer, which must be retained for subsequent reads. - If the stream returns the error `boost::asio::error::eof` indicating the + If the stream returns the error `net::error::eof` indicating the end of file during a read, the error returned from this function will be: @li @ref error::end_of_stream if no octets were parsed, or @@ -555,7 +555,7 @@ read( Regardless of whether the asynchronous operation completes immediately or not, the handler will not be invoked from within this function. Invocation of the handler will be performed in a - manner equivalent to using `boost::asio::io_context::post`. + manner equivalent to using `net::io_context::post`. @note The implementation will call @ref basic_parser::eager with the value `true` on the parser passed in. @@ -590,7 +590,7 @@ async_read( end of the message being read. This additional data is stored in the dynamic buffer, which must be retained for subsequent reads. - If the stream returns the error `boost::asio::error::eof` indicating the + If the stream returns the error `net::error::eof` indicating the end of file during a read, the error returned from this function will be: @li @ref error::end_of_stream if no octets were parsed, or @@ -644,7 +644,7 @@ read( end of the message being read. This additional data is stored in the dynamic buffer, which must be retained for subsequent reads. - If the stream returns the error `boost::asio::error::eof` indicating the + If the stream returns the error `net::error::eof` indicating the end of file during a read, the error returned from this function will be: @li @ref error::end_of_stream if no octets were parsed, or @@ -703,7 +703,7 @@ read( end of the message being read. This additional data is stored in the dynamic buffer, which must be retained for subsequent reads. - If the stream returns the error `boost::asio::error::eof` indicating the + If the stream returns the error `net::error::eof` indicating the end of file during a read, the error returned from this function will be: @li @ref error::end_of_stream if no octets were parsed, or @@ -741,7 +741,7 @@ read( Regardless of whether the asynchronous operation completes immediately or not, the handler will not be invoked from within this function. Invocation of the handler will be performed in a - manner equivalent to using `boost::asio::io_context::post`. + manner equivalent to using `net::io_context::post`. */ template< class AsyncReadStream, diff --git a/include/boost/beast/http/serializer.hpp b/include/boost/beast/http/serializer.hpp index 6ccfab8a..85222698 100644 --- a/include/boost/beast/http/serializer.hpp +++ b/include/boost/beast/http/serializer.hpp @@ -130,7 +130,7 @@ private: using cb4_t = buffers_suffix>; // crlf @@ -138,7 +138,7 @@ private: using cb5_t = buffers_suffix>; // crlf @@ -146,30 +146,30 @@ private: using cb6_t = buffers_suffix>; // crlf using pcb6_t = buffers_prefix_view; using cb7_t = buffers_suffix>; // crlf using pcb7_t = buffers_prefix_view; using cb8_t = buffers_suffix>; // crlf using pcb8_t = buffers_prefix_view; diff --git a/include/boost/beast/http/span_body.hpp b/include/boost/beast/http/span_body.hpp index 3926e81a..6bfb3729 100644 --- a/include/boost/beast/http/span_body.hpp +++ b/include/boost/beast/http/span_body.hpp @@ -95,8 +95,8 @@ public: put(ConstBufferSequence const& buffers, error_code& ec) { - using boost::asio::buffer_size; - using boost::asio::buffer_copy; + using net::buffer_size; + using net::buffer_copy; auto const n = buffer_size(buffers); auto const len = body_.size(); if(n > len) @@ -105,7 +105,7 @@ public: return 0; } ec.assign(0, ec.category()); - buffer_copy(boost::asio::buffer( + buffer_copy(net::buffer( body_.data(), n), buffers); body_ = value_type{ body_.data() + n, body_.size() - n}; @@ -133,7 +133,7 @@ public: public: using const_buffers_type = - boost::asio::const_buffer; + net::const_buffer; template explicit diff --git a/include/boost/beast/http/string_body.hpp b/include/boost/beast/http/string_body.hpp index 27320375..bc324b6f 100644 --- a/include/boost/beast/http/string_body.hpp +++ b/include/boost/beast/http/string_body.hpp @@ -117,8 +117,8 @@ public: put(ConstBufferSequence const& buffers, error_code& ec) { - using boost::asio::buffer_size; - using boost::asio::buffer_copy; + using net::buffer_size; + using net::buffer_copy; auto const extra = buffer_size(buffers); auto const size = body_.size(); try @@ -162,7 +162,7 @@ public: public: using const_buffers_type = - boost::asio::const_buffer; + net::const_buffer; template explicit diff --git a/include/boost/beast/http/type_traits.hpp b/include/boost/beast/http/type_traits.hpp index 037b8f37..ca653649 100644 --- a/include/boost/beast/http/type_traits.hpp +++ b/include/boost/beast/http/type_traits.hpp @@ -88,7 +88,7 @@ struct is_body_writer>&>() = std::declval().get(std::declval()) )>> : std::integral_constant::value && ( (std::is_constructible&, @@ -119,7 +119,7 @@ struct is_mutable_body_writer>&>() = std::declval().get(std::declval()) )>> : std::integral_constant::value && (( std::is_constructible&, @@ -171,7 +171,7 @@ struct is_body_reader()), std::declval() = std::declval().put( - std::declval(), + std::declval(), std::declval()), std::declval().finish( std::declval()) diff --git a/include/boost/beast/http/vector_body.hpp b/include/boost/beast/http/vector_body.hpp index 62d866f0..fdc8b9a6 100644 --- a/include/boost/beast/http/vector_body.hpp +++ b/include/boost/beast/http/vector_body.hpp @@ -111,8 +111,8 @@ public: put(ConstBufferSequence const& buffers, error_code& ec) { - using boost::asio::buffer_size; - using boost::asio::buffer_copy; + using net::buffer_size; + using net::buffer_copy; auto const n = buffer_size(buffers); auto const len = body_.size(); try @@ -125,7 +125,7 @@ public: return 0; } ec.assign(0, ec.category()); - return buffer_copy(boost::asio::buffer( + return buffer_copy(net::buffer( &body_[0] + len, n), buffers); } @@ -150,7 +150,7 @@ public: public: using const_buffers_type = - boost::asio::const_buffer; + net::const_buffer; template explicit diff --git a/include/boost/beast/http/write.hpp b/include/boost/beast/http/write.hpp index 422f9340..95631a15 100644 --- a/include/boost/beast/http/write.hpp +++ b/include/boost/beast/http/write.hpp @@ -159,7 +159,7 @@ write_some( Regardless of whether the asynchronous operation completes immediately or not, the handler will not be invoked from within this function. Invocation of the handler will be performed in a - manner equivalent to using `boost::asio::io_context::post`. + manner equivalent to using `net::io_context::post`. @see @ref serializer */ @@ -280,7 +280,7 @@ write_header( Regardless of whether the asynchronous operation completes immediately or not, the handler will not be invoked from within this function. Invocation of the handler will be performed in a - manner equivalent to using `boost::asio::io_context::post`. + manner equivalent to using `net::io_context::post`. @note The implementation will call @ref serializer::split with the value `true` on the serializer passed in. @@ -398,7 +398,7 @@ write( Regardless of whether the asynchronous operation completes immediately or not, the handler will not be invoked from within this function. Invocation of the handler will be performed in a - manner equivalent to using `boost::asio::io_context::post`. + manner equivalent to using `net::io_context::post`. @see @ref serializer */ @@ -617,7 +617,7 @@ write( Regardless of whether the asynchronous operation completes immediately or not, the handler will not be invoked from within this function. Invocation of the handler will be performed in a - manner equivalent to using `boost::asio::io_context::post`. + manner equivalent to using `net::io_context::post`. @see @ref message */ @@ -675,7 +675,7 @@ async_write( Regardless of whether the asynchronous operation completes immediately or not, the handler will not be invoked from within this function. Invocation of the handler will be performed in a - manner equivalent to using `boost::asio::io_context::post`. + manner equivalent to using `net::io_context::post`. @see @ref message */ diff --git a/include/boost/beast/websocket/detail/frame.hpp b/include/boost/beast/websocket/detail/frame.hpp index be79a8af..9c68774f 100644 --- a/include/boost/beast/websocket/detail/frame.hpp +++ b/include/boost/beast/websocket/detail/frame.hpp @@ -184,8 +184,8 @@ template void write(DynamicBuffer& db, frame_header const& fh) { - using boost::asio::buffer; - using boost::asio::buffer_copy; + using net::buffer; + using net::buffer_copy; using namespace boost::endian; std::size_t n; std::uint8_t b[14]; @@ -231,9 +231,9 @@ template void read_ping(ping_data& data, Buffers const& bs) { - using boost::asio::buffer_copy; - using boost::asio::buffer_size; - using boost::asio::mutable_buffer; + using net::buffer_copy; + using net::buffer_size; + using net::mutable_buffer; BOOST_ASSERT(buffer_size(bs) <= data.max_size()); data.resize(buffer_size(bs)); buffer_copy(mutable_buffer{ @@ -250,9 +250,9 @@ read_close( Buffers const& bs, error_code& ec) { - using boost::asio::buffer; - using boost::asio::buffer_copy; - using boost::asio::buffer_size; + using net::buffer; + using net::buffer_copy; + using net::buffer_size; using namespace boost::endian; auto n = buffer_size(bs); BOOST_ASSERT(n <= 125); diff --git a/include/boost/beast/websocket/detail/mask.hpp b/include/boost/beast/websocket/detail/mask.hpp index 3b30f9e3..cf3ecab1 100644 --- a/include/boost/beast/websocket/detail/mask.hpp +++ b/include/boost/beast/websocket/detail/mask.hpp @@ -49,7 +49,7 @@ rol(std::array& v, std::size_t n) // inline void -mask_inplace(boost::asio::mutable_buffer& b, prepared_key& key) +mask_inplace(net::mutable_buffer& b, prepared_key& key) { auto n = b.size(); auto mask = key; // avoid aliasing @@ -75,7 +75,7 @@ template void mask_inplace(MutableBuffers const& bs, KeyType& key) { - for(boost::asio::mutable_buffer b : + for(net::mutable_buffer b : beast::buffers_range(std::ref(bs))) mask_inplace(b, key); } diff --git a/include/boost/beast/websocket/detail/pausation.hpp b/include/boost/beast/websocket/detail/pausation.hpp index e3870b03..64d2a7ed 100644 --- a/include/boost/beast/websocket/detail/pausation.hpp +++ b/include/boost/beast/websocket/detail/pausation.hpp @@ -54,9 +54,9 @@ class pausation { Handler h(std::move(h_)); typename beast::detail::allocator_traits< - boost::asio::associated_allocator_t< + net::associated_allocator_t< Handler>>::template rebind_alloc alloc{ - boost::asio::get_associated_allocator(h)}; + net::get_associated_allocator(h)}; beast::detail::allocator_traits< decltype(alloc)>::destroy(alloc, this); beast::detail::allocator_traits< @@ -68,9 +68,9 @@ class pausation { Handler h(std::move(h_)); typename beast::detail::allocator_traits< - boost::asio::associated_allocator_t< + net::associated_allocator_t< Handler>>::template rebind_alloc alloc{ - boost::asio::get_associated_allocator(h)}; + net::get_associated_allocator(h)}; beast::detail::allocator_traits< decltype(alloc)>::destroy(alloc, this); beast::detail::allocator_traits< @@ -137,10 +137,10 @@ pausation::emplace(CompletionHandler&& handler) { BOOST_ASSERT(! h_); typename beast::detail::allocator_traits< - boost::asio::associated_allocator_t< + net::associated_allocator_t< CompletionHandler>>::template rebind_alloc< impl> alloc{ - boost::asio::get_associated_allocator(handler)}; + net::get_associated_allocator(handler)}; using A = decltype(alloc); auto const d = [&alloc](impl* p) diff --git a/include/boost/beast/websocket/detail/stream_base.hpp b/include/boost/beast/websocket/detail/stream_base.hpp index 110fbeee..b7a69391 100644 --- a/include/boost/beast/websocket/detail/stream_base.hpp +++ b/include/boost/beast/websocket/detail/stream_base.hpp @@ -340,7 +340,7 @@ struct stream_base : stream_prng template bool deflate( - boost::asio::mutable_buffer& out, + net::mutable_buffer& out, buffers_suffix& cb, bool fin, std::size_t& total_in, @@ -539,7 +539,7 @@ struct stream_base : stream_prng template bool deflate( - boost::asio::mutable_buffer&, + net::mutable_buffer&, buffers_suffix&, bool, std::size_t&, diff --git a/include/boost/beast/websocket/detail/utf8_checker.hpp b/include/boost/beast/websocket/detail/utf8_checker.hpp index 32a0a30f..7b09b337 100644 --- a/include/boost/beast/websocket/detail/utf8_checker.hpp +++ b/include/boost/beast/websocket/detail/utf8_checker.hpp @@ -86,7 +86,7 @@ bool utf8_checker_t<_>:: write(ConstBufferSequence const& bs) { - static_assert(boost::asio::is_const_buffer_sequence::value, + static_assert(net::is_const_buffer_sequence::value, "ConstBufferSequence requirements not met"); for(auto b : beast::buffers_range(std::ref(bs))) if(! write(static_cast< diff --git a/include/boost/beast/websocket/impl/accept.ipp b/include/boost/beast/websocket/impl/accept.ipp index ddc6290d..0e481a7a 100644 --- a/include/boost/beast/websocket/impl/accept.ipp +++ b/include/boost/beast/websocket/impl/accept.ipp @@ -40,12 +40,12 @@ namespace websocket { template template class stream::response_op - : public boost::asio::coroutine + : public net::coroutine { struct data { stream& ws; - boost::asio::executor_work_guard&>().get_executor())> wg; error_code result; response_type res; @@ -79,22 +79,22 @@ public: } using allocator_type = - boost::asio::associated_allocator_t; + net::associated_allocator_t; allocator_type get_allocator() const noexcept { - return (boost::asio::get_associated_allocator)(d_.handler()); + return (net::get_associated_allocator)(d_.handler()); } - using executor_type = boost::asio::associated_executor_t< + using executor_type = net::associated_executor_t< Handler, decltype(std::declval< stream&>().get_executor())>; executor_type get_executor() const noexcept { - return (boost::asio::get_associated_executor)( + return (net::get_associated_executor)( d_.handler(), d_->ws.get_executor()); } @@ -105,7 +105,7 @@ public: friend bool asio_handler_is_continuation(response_op* op) { - using boost::asio::asio_handler_is_continuation; + using net::asio_handler_is_continuation; return asio_handler_is_continuation( std::addressof(op->d_.handler())); } @@ -114,7 +114,7 @@ public: friend void asio_handler_invoke(Function&& f, response_op* op) { - using boost::asio::asio_handler_invoke; + using net::asio_handler_invoke; asio_handler_invoke(f, std::addressof(op->d_.handler())); } }; @@ -156,12 +156,12 @@ operator()( template template class stream::accept_op - : public boost::asio::coroutine + : public net::coroutine { struct data { stream& ws; - boost::asio::executor_work_guard&>().get_executor())> wg; Decorator decorator; http::request_parser p; @@ -191,21 +191,21 @@ public: } using allocator_type = - boost::asio::associated_allocator_t; + net::associated_allocator_t; allocator_type get_allocator() const noexcept { - return (boost::asio::get_associated_allocator)(d_.handler()); + return (net::get_associated_allocator)(d_.handler()); } - using executor_type = boost::asio::associated_executor_t< + using executor_type = net::associated_executor_t< Handler, decltype(std::declval&>().get_executor())>; executor_type get_executor() const noexcept { - return (boost::asio::get_associated_executor)( + return (net::get_associated_executor)( d_.handler(), d_->ws.get_executor()); } @@ -219,7 +219,7 @@ public: friend bool asio_handler_is_continuation(accept_op* op) { - using boost::asio::asio_handler_is_continuation; + using net::asio_handler_is_continuation; return asio_handler_is_continuation( std::addressof(op->d_.handler())); } @@ -228,7 +228,7 @@ public: friend void asio_handler_invoke(Function&& f, accept_op* op) { - using boost::asio::asio_handler_invoke; + using net::asio_handler_invoke; asio_handler_invoke(f, std::addressof(op->d_.handler())); } }; @@ -241,8 +241,8 @@ stream:: accept_op:: run(Buffers const& buffers) { - using boost::asio::buffer_copy; - using boost::asio::buffer_size; + using net::buffer_copy; + using net::buffer_size; auto& d = *d_; error_code ec; auto const mb = beast::detail::dynamic_buffer_prepare( @@ -267,7 +267,7 @@ operator()(error_code ec, std::size_t) if(ec) { BOOST_ASIO_CORO_YIELD - boost::asio::post( + net::post( d.ws.get_executor(), beast::bind_front_handler(std::move(*this), ec)); } @@ -375,7 +375,7 @@ accept(ConstBufferSequence const& buffers) { static_assert(is_sync_stream::value, "SyncStream requirements not met"); - static_assert(boost::asio::is_const_buffer_sequence< + static_assert(net::is_const_buffer_sequence< ConstBufferSequence>::value, "ConstBufferSequence requirements not met"); error_code ec; @@ -397,7 +397,7 @@ accept_ex( { static_assert(is_sync_stream::value, "SyncStream requirements not met"); - static_assert(boost::asio::is_const_buffer_sequence< + static_assert(net::is_const_buffer_sequence< ConstBufferSequence>::value, "ConstBufferSequence requirements not met"); static_assert(detail::is_response_decorator< @@ -419,11 +419,11 @@ accept( { static_assert(is_sync_stream::value, "SyncStream requirements not met"); - static_assert(boost::asio::is_const_buffer_sequence< + static_assert(net::is_const_buffer_sequence< ConstBufferSequence>::value, "ConstBufferSequence requirements not met"); - using boost::asio::buffer_copy; - using boost::asio::buffer_size; + using net::buffer_copy; + using net::buffer_size; reset(); auto const mb = beast::detail::dynamic_buffer_prepare( rd_buf_, buffer_size(buffers), ec, @@ -448,14 +448,14 @@ accept_ex( { static_assert(is_sync_stream::value, "SyncStream requirements not met"); - static_assert(boost::asio::is_const_buffer_sequence< + static_assert(net::is_const_buffer_sequence< ConstBufferSequence>::value, "ConstBufferSequence requirements not met"); - static_assert(boost::asio::is_const_buffer_sequence< + static_assert(net::is_const_buffer_sequence< ConstBufferSequence>::value, "ConstBufferSequence requirements not met"); - using boost::asio::buffer_copy; - using boost::asio::buffer_size; + using net::buffer_copy; + using net::buffer_size; reset(); auto const mb = beast::detail::dynamic_buffer_prepare( rd_buf_, buffer_size(buffers), ec, @@ -610,7 +610,7 @@ async_accept( { static_assert(is_async_stream::value, "AsyncStream requirements not met"); - static_assert(boost::asio::is_const_buffer_sequence< + static_assert(net::is_const_buffer_sequence< ConstBufferSequence>::value, "ConstBufferSequence requirements not met"); BOOST_BEAST_HANDLER_INIT( @@ -643,7 +643,7 @@ async_accept_ex( { static_assert(is_async_stream::value, "AsyncStream requirements not met"); - static_assert(boost::asio::is_const_buffer_sequence< + static_assert(net::is_const_buffer_sequence< ConstBufferSequence>::value, "ConstBufferSequence requirements not met"); static_assert(detail::is_response_decorator< @@ -678,7 +678,7 @@ async_accept( BOOST_BEAST_HANDLER_INIT( AcceptHandler, void(error_code)); reset(); - using boost::asio::asio_handler_is_continuation; + using net::asio_handler_is_continuation; response_op< BOOST_ASIO_HANDLER_TYPE( AcceptHandler, void(error_code))>{ @@ -710,7 +710,7 @@ async_accept_ex( BOOST_BEAST_HANDLER_INIT( AcceptHandler, void(error_code)); reset(); - using boost::asio::asio_handler_is_continuation; + using net::asio_handler_is_continuation; response_op< BOOST_ASIO_HANDLER_TYPE( AcceptHandler, void(error_code))>{ diff --git a/include/boost/beast/websocket/impl/close.ipp b/include/boost/beast/websocket/impl/close.ipp index 834fa229..d1bb330f 100644 --- a/include/boost/beast/websocket/impl/close.ipp +++ b/include/boost/beast/websocket/impl/close.ipp @@ -39,12 +39,12 @@ namespace websocket { template template class stream::close_op - : public boost::asio::coroutine + : public net::coroutine { struct state { stream& ws; - boost::asio::executor_work_guard&>().get_executor())> wg; detail::frame_buffer fb; error_code ev; @@ -81,21 +81,21 @@ public: } using allocator_type = - boost::asio::associated_allocator_t; + net::associated_allocator_t; allocator_type get_allocator() const noexcept { - return (boost::asio::get_associated_allocator)(d_.handler()); + return (net::get_associated_allocator)(d_.handler()); } - using executor_type = boost::asio::associated_executor_t< + using executor_type = net::associated_executor_t< Handler, decltype(std::declval&>().get_executor())>; executor_type get_executor() const noexcept { - return (boost::asio::get_associated_executor)( + return (net::get_associated_executor)( d_.handler(), d_->ws.get_executor()); } @@ -108,7 +108,7 @@ public: friend bool asio_handler_is_continuation(close_op* op) { - using boost::asio::asio_handler_is_continuation; + using net::asio_handler_is_continuation; return op->d_->cont || asio_handler_is_continuation( std::addressof(op->d_.handler())); } @@ -117,7 +117,7 @@ public: friend void asio_handler_invoke(Function&& f, close_op* op) { - using boost::asio::asio_handler_invoke; + using net::asio_handler_invoke; asio_handler_invoke(f, std::addressof(op->d_.handler())); } @@ -150,7 +150,7 @@ operator()( // Resume BOOST_ASIO_CORO_YIELD - boost::asio::post( + net::post( d.ws.get_executor(), std::move(*this)); BOOST_ASSERT(d.ws.wr_block_.is_locked(this)); } @@ -169,7 +169,7 @@ operator()( // Send close frame d.ws.wr_close_ = true; BOOST_ASIO_CORO_YIELD - boost::asio::async_write(d.ws.stream_, + net::async_write(d.ws.stream_, d.fb.data(), std::move(*this)); if(! d.ws.check_ok(ec)) goto upcall; @@ -194,7 +194,7 @@ operator()( // Resume BOOST_ASIO_CORO_YIELD - boost::asio::post( + net::post( d.ws.get_executor(), std::move(*this)); BOOST_ASSERT(d.ws.rd_block_.is_locked(this)); @@ -277,7 +277,7 @@ operator()( async_teardown(d.ws.role_, d.ws.stream_, std::move(*this)); BOOST_ASSERT(d.ws.wr_block_.is_locked(this)); - if(ec == boost::asio::error::eof) + if(ec == net::error::eof) { // Rationale: // http://stackoverflow.com/questions/25587403/boost-asio-ssl-async-shutdown-always-finishes-with-an-error @@ -302,7 +302,7 @@ operator()( if(! d.cont) { BOOST_ASIO_CORO_YIELD - boost::asio::post( + net::post( d.ws.get_executor(), beast::bind_front_handler(std::move(*this), ec)); } @@ -347,7 +347,7 @@ close(close_reason const& cr, error_code& ec) { detail::frame_buffer fb; write_close(fb, cr); - boost::asio::write(stream_, fb.data(), ec); + net::write(stream_, fb.data(), ec); } if(! check_ok(ec)) return; diff --git a/include/boost/beast/websocket/impl/handshake.ipp b/include/boost/beast/websocket/impl/handshake.ipp index 63b7ac2a..4c78b3f6 100644 --- a/include/boost/beast/websocket/impl/handshake.ipp +++ b/include/boost/beast/websocket/impl/handshake.ipp @@ -38,12 +38,12 @@ namespace websocket { template template class stream::handshake_op - : public boost::asio::coroutine + : public net::coroutine { struct data { stream& ws; - boost::asio::executor_work_guard&>().get_executor())> wg; response_type* res_p; detail::sec_ws_key_type key; @@ -83,21 +83,21 @@ public: } using allocator_type = - boost::asio::associated_allocator_t; + net::associated_allocator_t; allocator_type get_allocator() const noexcept { - return (boost::asio::get_associated_allocator)(d_.handler()); + return (net::get_associated_allocator)(d_.handler()); } - using executor_type = boost::asio::associated_executor_t< + using executor_type = net::associated_executor_t< Handler, decltype(std::declval&>().get_executor())>; executor_type get_executor() const noexcept { - return (boost::asio::get_associated_executor)( + return (net::get_associated_executor)( d_.handler(), d_->ws.get_executor()); } @@ -109,7 +109,7 @@ public: friend bool asio_handler_is_continuation(handshake_op* op) { - using boost::asio::asio_handler_is_continuation; + using net::asio_handler_is_continuation; return asio_handler_is_continuation( std::addressof(op->d_.handler())); } @@ -118,7 +118,7 @@ public: friend void asio_handler_invoke(Function&& f, handshake_op* op) { - using boost::asio::asio_handler_invoke; + using net::asio_handler_invoke; asio_handler_invoke(f, std::addressof(op->d_.handler())); } diff --git a/include/boost/beast/websocket/impl/ping.ipp b/include/boost/beast/websocket/impl/ping.ipp index 41fcf806..20e85dcc 100644 --- a/include/boost/beast/websocket/impl/ping.ipp +++ b/include/boost/beast/websocket/impl/ping.ipp @@ -37,12 +37,12 @@ namespace websocket { template template class stream::ping_op - : public boost::asio::coroutine + : public net::coroutine { struct state { stream& ws; - boost::asio::executor_work_guard&>().get_executor())> wg; detail::frame_buffer fb; @@ -81,21 +81,21 @@ public: } using allocator_type = - boost::asio::associated_allocator_t; + net::associated_allocator_t; allocator_type get_allocator() const noexcept { - return (boost::asio::get_associated_allocator)(d_.handler()); + return (net::get_associated_allocator)(d_.handler()); } - using executor_type = boost::asio::associated_executor_t< + using executor_type = net::associated_executor_t< Handler, decltype(std::declval&>().get_executor())>; executor_type get_executor() const noexcept { - return (boost::asio::get_associated_executor)( + return (net::get_associated_executor)( d_.handler(), d_->ws.get_executor()); } @@ -106,7 +106,7 @@ public: friend bool asio_handler_is_continuation(ping_op* op) { - using boost::asio::asio_handler_is_continuation; + using net::asio_handler_is_continuation; return asio_handler_is_continuation( std::addressof(op->d_.handler())); } @@ -115,7 +115,7 @@ public: friend void asio_handler_invoke(Function&& f, ping_op* op) { - using boost::asio::asio_handler_invoke; + using net::asio_handler_invoke; asio_handler_invoke( f, std::addressof(op->d_.handler())); } @@ -138,7 +138,7 @@ operator()(error_code ec, std::size_t) if(! d.ws.check_open(ec)) { BOOST_ASIO_CORO_YIELD - boost::asio::post( + net::post( d.ws.get_executor(), beast::bind_front_handler(std::move(*this), ec)); goto upcall; @@ -155,7 +155,7 @@ operator()(error_code ec, std::size_t) // Resume BOOST_ASIO_CORO_YIELD - boost::asio::post( + net::post( d.ws.get_executor(), std::move(*this)); BOOST_ASSERT(d.ws.wr_block_.is_locked(this)); @@ -166,7 +166,7 @@ operator()(error_code ec, std::size_t) // Send ping frame BOOST_ASIO_CORO_YIELD - boost::asio::async_write(d.ws.stream_, + net::async_write(d.ws.stream_, d.fb.data(), std::move(*this)); if(! d.ws.check_ok(ec)) goto upcall; @@ -207,7 +207,7 @@ ping(ping_data const& payload, error_code& ec) detail::frame_buffer fb; write_ping( fb, detail::opcode::ping, payload); - boost::asio::write(stream_, fb.data(), ec); + net::write(stream_, fb.data(), ec); if(! check_ok(ec)) return; } @@ -234,7 +234,7 @@ pong(ping_data const& payload, error_code& ec) detail::frame_buffer fb; write_ping( fb, detail::opcode::pong, payload); - boost::asio::write(stream_, fb.data(), ec); + net::write(stream_, fb.data(), ec); if(! check_ok(ec)) return; } diff --git a/include/boost/beast/websocket/impl/read.ipp b/include/boost/beast/websocket/impl/read.ipp index 6aa547db..a146832b 100644 --- a/include/boost/beast/websocket/impl/read.ipp +++ b/include/boost/beast/websocket/impl/read.ipp @@ -80,11 +80,11 @@ template< class MutableBufferSequence, class Handler> class stream::read_some_op - : public boost::asio::coroutine + : public net::coroutine { Handler h_; stream& ws_; - boost::asio::executor_work_guard&>().get_executor())> wg_; MutableBufferSequence bs_; buffers_suffix cb_; @@ -115,21 +115,21 @@ public: } using allocator_type = - boost::asio::associated_allocator_t; + net::associated_allocator_t; allocator_type get_allocator() const noexcept { - return (boost::asio::get_associated_allocator)(h_); + return (net::get_associated_allocator)(h_); } - using executor_type = boost::asio::associated_executor_t< + using executor_type = net::associated_executor_t< Handler, decltype(std::declval&>().get_executor())>; executor_type get_executor() const noexcept { - return (boost::asio::get_associated_executor)( + return (net::get_associated_executor)( h_, ws_.get_executor()); } @@ -147,7 +147,7 @@ public: friend bool asio_handler_is_continuation(read_some_op* op) { - using boost::asio::asio_handler_is_continuation; + using net::asio_handler_is_continuation; return op->cont_ || asio_handler_is_continuation( std::addressof(op->h_)); } @@ -156,7 +156,7 @@ public: friend void asio_handler_invoke(Function&& f, read_some_op* op) { - using boost::asio::asio_handler_invoke; + using net::asio_handler_invoke; asio_handler_invoke(f, std::addressof(op->h_)); } }; @@ -172,8 +172,8 @@ operator()( bool cont) { using beast::detail::clamp; - using boost::asio::buffer; - using boost::asio::buffer_size; + using net::buffer; + using net::buffer_size; cont_ = cont; BOOST_ASIO_CORO_REENTER(*this) { @@ -185,7 +185,7 @@ operator()( if( ws_.status_ == status::closed || ws_.status_ == status::failed) { - ec = boost::asio::error::operation_aborted; + ec = net::error::operation_aborted; goto upcall; } } @@ -201,7 +201,7 @@ operator()( // Resume BOOST_ASIO_CORO_YIELD - boost::asio::post( + net::post( ws_.get_executor(), std::move(*this)); BOOST_ASSERT(ws_.rd_block_.is_locked(this)); @@ -209,7 +209,7 @@ operator()( // a `close_op` wrote a close frame BOOST_ASSERT(ws_.wr_close_); BOOST_ASSERT(ws_.status_ != status::open); - ec = boost::asio::error::operation_aborted; + ec = net::error::operation_aborted; goto upcall; } @@ -283,7 +283,7 @@ operator()( if(! cont_) { BOOST_ASIO_CORO_YIELD - boost::asio::post( + net::post( ws_.get_executor(), std::move(*this)); BOOST_ASSERT(cont_); @@ -327,7 +327,7 @@ operator()( // Resume BOOST_ASIO_CORO_YIELD - boost::asio::post( + net::post( ws_.get_executor(), std::move(*this)); BOOST_ASSERT(ws_.wr_block_.is_locked(this)); @@ -339,7 +339,7 @@ operator()( // Send pong BOOST_ASSERT(ws_.wr_block_.is_locked(this)); BOOST_ASIO_CORO_YIELD - boost::asio::async_write(ws_.stream_, + net::async_write(ws_.stream_, ws_.rd_fb_.data(), std::move(*this)); BOOST_ASSERT(ws_.wr_block_.is_locked(this)); if(! ws_.check_ok(ec)) @@ -359,7 +359,7 @@ operator()( if(! cont_) { BOOST_ASIO_CORO_YIELD - boost::asio::post( + net::post( ws_.get_executor(), std::move(*this)); BOOST_ASSERT(cont_); @@ -385,7 +385,7 @@ operator()( if(! cont_) { BOOST_ASIO_CORO_YIELD - boost::asio::post( + net::post( ws_.get_executor(), std::move(*this)); BOOST_ASSERT(cont_); @@ -461,7 +461,7 @@ operator()( { // Copy from the read buffer. // The mask was already applied. - bytes_transferred = boost::asio::buffer_copy(cb_, + bytes_transferred = net::buffer_copy(cb_, ws_.rd_buf_.data(), clamp(ws_.rd_remain_)); auto const mb = buffers_prefix( bytes_transferred, cb_); @@ -639,7 +639,7 @@ operator()( // Resume BOOST_ASIO_CORO_YIELD - boost::asio::post( + net::post( ws_.get_executor(), std::move(*this)); BOOST_ASSERT(ws_.wr_block_.is_locked(this)); @@ -664,7 +664,7 @@ operator()( // Send close frame BOOST_ASSERT(ws_.wr_block_.is_locked(this)); BOOST_ASIO_CORO_YIELD - boost::asio::async_write( + net::async_write( ws_.stream_, ws_.rd_fb_.data(), std::move(*this)); BOOST_ASSERT(ws_.wr_block_.is_locked(this)); @@ -679,7 +679,7 @@ operator()( async_teardown(ws_.role_, ws_.stream_, std::move(*this)); BOOST_ASSERT(ws_.wr_block_.is_locked(this)); - if(ec == boost::asio::error::eof) + if(ec == net::error::eof) { // Rationale: // http://stackoverflow.com/questions/25587403/boost-asio-ssl-async-shutdown-always-finishes-with-an-error @@ -703,7 +703,7 @@ operator()( if(! cont_) { BOOST_ASIO_CORO_YIELD - boost::asio::post( + net::post( ws_.get_executor(), beast::bind_front_handler(std::move(*this), ec, bytes_written_)); @@ -719,11 +719,11 @@ template< class DynamicBuffer, class Handler> class stream::read_op - : public boost::asio::coroutine + : public net::coroutine { Handler h_; stream& ws_; - boost::asio::executor_work_guard&>().get_executor())> wg_; DynamicBuffer& b_; std::size_t limit_; @@ -732,7 +732,7 @@ class stream::read_op public: using allocator_type = - boost::asio::associated_allocator_t; + net::associated_allocator_t; read_op(read_op&&) = default; read_op(read_op const&) = delete; @@ -757,16 +757,16 @@ public: allocator_type get_allocator() const noexcept { - return (boost::asio::get_associated_allocator)(h_); + return (net::get_associated_allocator)(h_); } - using executor_type = boost::asio::associated_executor_t< + using executor_type = net::associated_executor_t< Handler, decltype(std::declval&>().get_executor())>; executor_type get_executor() const noexcept { - return (boost::asio::get_associated_executor)( + return (net::get_associated_executor)( h_, ws_.get_executor()); } @@ -777,7 +777,7 @@ public: friend bool asio_handler_is_continuation(read_op* op) { - using boost::asio::asio_handler_is_continuation; + using net::asio_handler_is_continuation; return asio_handler_is_continuation( std::addressof(op->h_)); } @@ -786,7 +786,7 @@ public: friend void asio_handler_invoke(Function&& f, read_op* op) { - using boost::asio::asio_handler_invoke; + using net::asio_handler_invoke; asio_handler_invoke(f, std::addressof(op->h_)); } }; @@ -811,7 +811,7 @@ operator()( clamp(ws_.read_size_hint(b_), limit_), ec, error::buffer_overflow); if(ec) - boost::asio::post( + net::post( ws_.get_executor(), beast::bind_front_handler( std::move(*this), ec, 0)); @@ -843,7 +843,7 @@ read(DynamicBuffer& buffer) static_assert(is_sync_stream::value, "SyncStream requirements not met"); static_assert( - boost::asio::is_dynamic_buffer::value, + net::is_dynamic_buffer::value, "DynamicBuffer requirements not met"); error_code ec; auto const bytes_written = read(buffer, ec); @@ -861,7 +861,7 @@ read(DynamicBuffer& buffer, error_code& ec) static_assert(is_sync_stream::value, "SyncStream requirements not met"); static_assert( - boost::asio::is_dynamic_buffer::value, + net::is_dynamic_buffer::value, "DynamicBuffer requirements not met"); std::size_t bytes_written = 0; do @@ -884,7 +884,7 @@ async_read(DynamicBuffer& buffer, ReadHandler&& handler) static_assert(is_async_stream::value, "AsyncStream requirements not met"); static_assert( - boost::asio::is_dynamic_buffer::value, + net::is_dynamic_buffer::value, "DynamicBuffer requirements not met"); BOOST_BEAST_HANDLER_INIT( ReadHandler, void(error_code, std::size_t)); @@ -913,7 +913,7 @@ read_some( static_assert(is_sync_stream::value, "SyncStream requirements not met"); static_assert( - boost::asio::is_dynamic_buffer::value, + net::is_dynamic_buffer::value, "DynamicBuffer requirements not met"); error_code ec; auto const bytes_written = @@ -935,7 +935,7 @@ read_some( static_assert(is_sync_stream::value, "SyncStream requirements not met"); static_assert( - boost::asio::is_dynamic_buffer::value, + net::is_dynamic_buffer::value, "DynamicBuffer requirements not met"); using beast::detail::clamp; if(! limit) @@ -965,7 +965,7 @@ async_read_some( static_assert(is_async_stream::value, "AsyncStream requirements not met"); static_assert( - boost::asio::is_dynamic_buffer::value, + net::is_dynamic_buffer::value, "DynamicBuffer requirements not met"); BOOST_BEAST_HANDLER_INIT( ReadHandler, void(error_code, std::size_t)); @@ -992,7 +992,7 @@ read_some( { static_assert(is_sync_stream::value, "SyncStream requirements not met"); - static_assert(boost::asio::is_mutable_buffer_sequence< + static_assert(net::is_mutable_buffer_sequence< MutableBufferSequence>::value, "MutableBufferSequence requirements not met"); error_code ec; @@ -1012,12 +1012,12 @@ read_some( { static_assert(is_sync_stream::value, "SyncStream requirements not met"); - static_assert(boost::asio::is_mutable_buffer_sequence< + static_assert(net::is_mutable_buffer_sequence< MutableBufferSequence>::value, "MutableBufferSequence requirements not met"); using beast::detail::clamp; - using boost::asio::buffer; - using boost::asio::buffer_size; + using net::buffer; + using net::buffer_size; close_code code{}; std::size_t bytes_written = 0; ec.assign(0, ec.category()); @@ -1088,7 +1088,7 @@ loop: detail::frame_buffer fb; write_ping(fb, detail::opcode::pong, payload); - boost::asio::write(stream_, fb.data(), ec); + net::write(stream_, fb.data(), ec); if(! check_ok(ec)) return bytes_written; goto loop; @@ -1167,7 +1167,7 @@ loop: // Copy from the read buffer. // The mask was already applied. auto const bytes_transferred = - boost::asio::buffer_copy(buffers, + net::buffer_copy(buffers, rd_buf_.data(), clamp(rd_remain_)); auto const mb = buffers_prefix( bytes_transferred, buffers); @@ -1349,7 +1349,7 @@ async_read_some( { static_assert(is_async_stream::value, "AsyncStream requirements not met"); - static_assert(boost::asio::is_mutable_buffer_sequence< + static_assert(net::is_mutable_buffer_sequence< MutableBufferSequence>::value, "MutableBufferSequence requirements not met"); BOOST_BEAST_HANDLER_INIT( diff --git a/include/boost/beast/websocket/impl/ssl.ipp b/include/boost/beast/websocket/impl/ssl.ipp index 442b4508..4338386e 100644 --- a/include/boost/beast/websocket/impl/ssl.ipp +++ b/include/boost/beast/websocket/impl/ssl.ipp @@ -35,7 +35,7 @@ template void teardown( role_type, - boost::asio::ssl::stream& stream, + net::ssl::stream& stream, error_code& ec) { stream.shutdown(ec); @@ -47,7 +47,7 @@ template< void async_teardown( role_type, - boost::asio::ssl::stream& stream, + net::ssl::stream& stream, TeardownHandler&& handler) { stream.async_shutdown( diff --git a/include/boost/beast/websocket/impl/stream.ipp b/include/boost/beast/websocket/impl/stream.ipp index 43fcb06e..f6584a9d 100644 --- a/include/boost/beast/websocket/impl/stream.ipp +++ b/include/boost/beast/websocket/impl/stream.ipp @@ -57,7 +57,7 @@ stream:: read_size_hint(DynamicBuffer& buffer) const { static_assert( - boost::asio::is_dynamic_buffer::value, + net::is_dynamic_buffer::value, "DynamicBuffer requirements not met"); auto const initial_size = (std::min)( +tcp_frame_size, @@ -169,9 +169,9 @@ parse_fh( DynamicBuffer& b, error_code& ec) { - using boost::asio::buffer; - using boost::asio::buffer_copy; - using boost::asio::buffer_size; + using net::buffer; + using net::buffer_copy; + using net::buffer_size; if(buffer_size(b.data()) < 2) { // need more bytes @@ -403,8 +403,8 @@ write_close(DynamicBuffer& db, close_reason const& cr) ::new(&tmp[0]) big_uint16_buf_t{ (std::uint16_t)cr.code}; auto mb = db.prepare(2); - boost::asio::buffer_copy(mb, - boost::asio::buffer(tmp)); + net::buffer_copy(mb, + net::buffer(tmp)); if(fh.mask) detail::mask_inplace(mb, key); db.commit(2); @@ -412,8 +412,8 @@ write_close(DynamicBuffer& db, close_reason const& cr) if(! cr.reason.empty()) { auto mb = db.prepare(cr.reason.size()); - boost::asio::buffer_copy(mb, - boost::asio::const_buffer( + net::buffer_copy(mb, + net::const_buffer( cr.reason.data(), cr.reason.size())); if(fh.mask) detail::mask_inplace(mb, key); @@ -446,8 +446,8 @@ write_ping(DynamicBuffer& db, if(fh.mask) detail::prepare_key(key, fh.key); auto mb = db.prepare(data.size()); - boost::asio::buffer_copy(mb, - boost::asio::const_buffer( + net::buffer_copy(mb, + net::const_buffer( data.data(), data.size())); if(fh.mask) detail::mask_inplace(mb, key); @@ -642,13 +642,13 @@ do_fail( detail::frame_buffer fb; write_close< flat_static_buffer_base>(fb, code); - boost::asio::write(stream_, fb.data(), ec); + net::write(stream_, fb.data(), ec); if(! check_ok(ec)) return; } using beast::websocket::teardown; teardown(role_, stream_, ec); - if(ec == boost::asio::error::eof) + if(ec == net::error::eof) { // Rationale: // http://stackoverflow.com/questions/25587403/boost-asio-ssl-async-shutdown-always-finishes-with-an-error diff --git a/include/boost/beast/websocket/impl/teardown.ipp b/include/boost/beast/websocket/impl/teardown.ipp index 3462f8d4..ed03672e 100644 --- a/include/boost/beast/websocket/impl/teardown.ipp +++ b/include/boost/beast/websocket/impl/teardown.ipp @@ -28,14 +28,14 @@ namespace websocket { namespace detail { template -class teardown_tcp_op : public boost::asio::coroutine +class teardown_tcp_op : public net::coroutine { using socket_type = - boost::asio::ip::tcp::socket; + net::ip::tcp::socket; Handler h_; socket_type& s_; - boost::asio::executor_work_guard().get_executor())> wg_; role_type role_; bool nb_; @@ -57,21 +57,21 @@ public: } using allocator_type = - boost::asio::associated_allocator_t; + net::associated_allocator_t; allocator_type get_allocator() const noexcept { - return (boost::asio::get_associated_allocator)(h_); + return (net::get_associated_allocator)(h_); } - using executor_type = boost::asio::associated_executor_t< + using executor_type = net::associated_executor_t< Handler, decltype(std::declval().get_executor())>; executor_type get_executor() const noexcept { - return (boost::asio::get_associated_executor)( + return (net::get_associated_executor)( h_, s_.get_executor()); } @@ -83,7 +83,7 @@ public: friend bool asio_handler_is_continuation(teardown_tcp_op* op) { - using boost::asio::asio_handler_is_continuation; + using net::asio_handler_is_continuation; return asio_handler_is_continuation( std::addressof(op->h_)); } @@ -92,7 +92,7 @@ public: friend void asio_handler_invoke(Function&& f, teardown_tcp_op* op) { - using boost::asio::asio_handler_invoke; + using net::asio_handler_invoke; asio_handler_invoke(f, std::addressof(op->h_)); } }; @@ -102,8 +102,8 @@ void teardown_tcp_op:: operator()(error_code ec, std::size_t bytes_transferred) { - using boost::asio::buffer; - using tcp = boost::asio::ip::tcp; + using net::buffer; + using tcp = net::ip::tcp; BOOST_ASIO_CORO_REENTER(*this) { nb_ = s_.non_blocking(); @@ -116,7 +116,7 @@ operator()(error_code ec, std::size_t bytes_transferred) if(ec) { BOOST_ASIO_CORO_YIELD - boost::asio::post( + net::post( s_.get_executor(), beast::bind_front_handler(std::move(*this), ec, 0)); goto upcall; @@ -126,19 +126,19 @@ operator()(error_code ec, std::size_t bytes_transferred) { char buf[2048]; s_.read_some( - boost::asio::buffer(buf), ec); + net::buffer(buf), ec); } - if(ec == boost::asio::error::would_block) + if(ec == net::error::would_block) { BOOST_ASIO_CORO_YIELD s_.async_wait( - boost::asio::ip::tcp::socket::wait_read, + net::ip::tcp::socket::wait_read, std::move(*this)); continue; } if(ec) { - if(ec != boost::asio::error::eof) + if(ec != net::error::eof) goto upcall; ec = {}; break; @@ -171,13 +171,13 @@ inline void teardown( role_type role, - boost::asio::ip::tcp::socket& socket, + net::ip::tcp::socket& socket, error_code& ec) { - using boost::asio::buffer; + using net::buffer; if(role == role_type::server) socket.shutdown( - boost::asio::ip::tcp::socket::shutdown_send, ec); + net::ip::tcp::socket::shutdown_send, ec); if(ec) return; for(;;) @@ -187,7 +187,7 @@ teardown( socket.read_some(buffer(buf), ec); if(ec) { - if(ec != boost::asio::error::eof) + if(ec != net::error::eof) return; ec = {}; break; @@ -200,7 +200,7 @@ teardown( } if(role == role_type::client) socket.shutdown( - boost::asio::ip::tcp::socket::shutdown_send, ec); + net::ip::tcp::socket::shutdown_send, ec); if(ec) return; socket.close(ec); @@ -211,7 +211,7 @@ inline void async_teardown( role_type role, - boost::asio::ip::tcp::socket& socket, + net::ip::tcp::socket& socket, TeardownHandler&& handler) { static_assert(beast::is_completion_handler< diff --git a/include/boost/beast/websocket/impl/write.ipp b/include/boost/beast/websocket/impl/write.ipp index 52a34b0d..765462df 100644 --- a/include/boost/beast/websocket/impl/write.ipp +++ b/include/boost/beast/websocket/impl/write.ipp @@ -46,13 +46,13 @@ template bool stream_base:: deflate( - boost::asio::mutable_buffer& out, + net::mutable_buffer& out, buffers_suffix& cb, bool fin, std::size_t& total_in, error_code& ec) { - using boost::asio::buffer; + using net::buffer; BOOST_ASSERT(out.size() >= 6); auto& zo = this->pmd_->zo; zlib::z_params zs; @@ -87,7 +87,7 @@ deflate( cb.consume(zs.total_in); if(zs.avail_out > 0 && fin) { - auto const remain = boost::asio::buffer_size(cb); + auto const remain = net::buffer_size(cb); if(remain == 0) { // Inspired by Mark Adler @@ -139,11 +139,11 @@ do_context_takeover_write(role_type role) template template class stream::write_some_op - : public boost::asio::coroutine + : public net::coroutine { Handler h_; stream& ws_; - boost::asio::executor_work_guard&>().get_executor())> wg_; buffers_suffix cb_; detail::frame_header fh_; @@ -177,21 +177,21 @@ public: } using allocator_type = - boost::asio::associated_allocator_t; + net::associated_allocator_t; allocator_type get_allocator() const noexcept { - return (boost::asio::get_associated_allocator)(h_); + return (net::get_associated_allocator)(h_); } - using executor_type = boost::asio::associated_executor_t< + using executor_type = net::associated_executor_t< Handler, decltype(std::declval&>().get_executor())>; executor_type get_executor() const noexcept { - return (boost::asio::get_associated_executor)( + return (net::get_associated_executor)( h_, ws_.get_executor()); } @@ -209,7 +209,7 @@ public: friend bool asio_handler_is_continuation(write_some_op* op) { - using boost::asio::asio_handler_is_continuation; + using net::asio_handler_is_continuation; return op->cont_ || asio_handler_is_continuation( std::addressof(op->h_)); } @@ -218,7 +218,7 @@ public: friend void asio_handler_invoke(Function&& f, write_some_op* op) { - using boost::asio::asio_handler_invoke; + using net::asio_handler_invoke; asio_handler_invoke( f, std::addressof(op->h_)); } @@ -235,10 +235,10 @@ operator()( bool cont) { using beast::detail::clamp; - using boost::asio::buffer; - using boost::asio::buffer_copy; - using boost::asio::buffer_size; - using boost::asio::mutable_buffer; + using net::buffer; + using net::buffer_copy; + using net::buffer_size; + using net::mutable_buffer; enum { do_nomask_nofrag, @@ -248,7 +248,7 @@ operator()( do_deflate }; std::size_t n; - boost::asio::mutable_buffer b; + net::mutable_buffer b; cont_ = cont; BOOST_ASIO_CORO_REENTER(*this) { @@ -326,7 +326,7 @@ operator()( // Resume BOOST_ASIO_CORO_YIELD - boost::asio::post( + net::post( ws_.get_executor(), std::move(*this)); BOOST_ASSERT(ws_.wr_block_.is_locked(this)); @@ -347,7 +347,7 @@ operator()( ws_.wr_cont_ = ! fin_; // Send frame BOOST_ASIO_CORO_YIELD - boost::asio::async_write(ws_.stream_, + net::async_write(ws_.stream_, buffers_cat(ws_.wr_fb_.data(), cb_), std::move(*this)); if(! ws_.check_ok(ec)) @@ -372,7 +372,7 @@ operator()( ws_.wr_cont_ = ! fin_; // Send frame BOOST_ASIO_CORO_YIELD - boost::asio::async_write( + net::async_write( ws_.stream_, buffers_cat( ws_.wr_fb_.data(), buffers_prefix( clamp(fh_.len), cb_)), @@ -421,7 +421,7 @@ operator()( ws_.wr_cont_ = ! fin_; // Send frame header and partial payload BOOST_ASIO_CORO_YIELD - boost::asio::async_write( + net::async_write( ws_.stream_, buffers_cat(ws_.wr_fb_.data(), buffer(ws_.wr_buf_.get(), n)), std::move(*this)); @@ -440,7 +440,7 @@ operator()( remain_ -= n; // Send partial payload BOOST_ASIO_CORO_YIELD - boost::asio::async_write(ws_.stream_, + net::async_write(ws_.stream_, buffer(ws_.wr_buf_.get(), n), std::move(*this)); if(! ws_.check_ok(ec)) @@ -472,7 +472,7 @@ operator()( ws_.wr_cont_ = ! fin_; // Send frame BOOST_ASIO_CORO_YIELD - boost::asio::async_write(ws_.stream_, + net::async_write(ws_.stream_, buffers_cat(ws_.wr_fb_.data(), buffer(ws_.wr_buf_.get(), n)), std::move(*this)); @@ -535,7 +535,7 @@ operator()( ws_.wr_cont_ = ! fin_; // Send frame BOOST_ASIO_CORO_YIELD - boost::asio::async_write(ws_.stream_, + net::async_write(ws_.stream_, buffers_cat(ws_.wr_fb_.data(), b), std::move(*this)); if(! ws_.check_ok(ec)) @@ -576,7 +576,7 @@ operator()( if(! cont_) { BOOST_ASIO_CORO_YIELD - boost::asio::post( + net::post( ws_.get_executor(), beast::bind_front_handler( std::move(*this), @@ -596,7 +596,7 @@ write_some(bool fin, ConstBufferSequence const& buffers) { static_assert(is_sync_stream::value, "SyncStream requirements not met"); - static_assert(boost::asio::is_const_buffer_sequence< + static_assert(net::is_const_buffer_sequence< ConstBufferSequence>::value, "ConstBufferSequence requirements not met"); error_code ec; @@ -616,13 +616,13 @@ write_some(bool fin, { static_assert(is_sync_stream::value, "SyncStream requirements not met"); - static_assert(boost::asio::is_const_buffer_sequence< + static_assert(net::is_const_buffer_sequence< ConstBufferSequence>::value, "ConstBufferSequence requirements not met"); using beast::detail::clamp; - using boost::asio::buffer; - using boost::asio::buffer_copy; - using boost::asio::buffer_size; + using net::buffer; + using net::buffer_copy; + using net::buffer_size; std::size_t bytes_transferred = 0; ec.assign(0, ec.category()); // Make sure the stream is open @@ -680,7 +680,7 @@ write_some(bool fin, detail::write< flat_static_buffer_base>(fh_buf, fh); wr_cont_ = ! fin; - boost::asio::write(stream_, + net::write(stream_, buffers_cat(fh_buf.data(), b), ec); if(! check_ok(ec)) return bytes_transferred; @@ -703,7 +703,7 @@ write_some(bool fin, detail::write< flat_static_buffer_base>(fh_buf, fh); wr_cont_ = ! fin; - boost::asio::write(stream_, + net::write(stream_, buffers_cat(fh_buf.data(), buffers), ec); if(! check_ok(ec)) return bytes_transferred; @@ -725,7 +725,7 @@ write_some(bool fin, detail::write< flat_static_buffer_base>(fh_buf, fh); wr_cont_ = ! fin; - boost::asio::write(stream_, + net::write(stream_, buffers_cat(fh_buf.data(), buffers_prefix(n, cb)), ec); if(! check_ok(ec)) @@ -759,7 +759,7 @@ write_some(bool fin, remain -= n; detail::mask_inplace(b, key); wr_cont_ = ! fin; - boost::asio::write(stream_, + net::write(stream_, buffers_cat(fh_buf.data(), b), ec); if(! check_ok(ec)) return bytes_transferred; @@ -773,7 +773,7 @@ write_some(bool fin, cb.consume(n); remain -= n; detail::mask_inplace(b, key); - boost::asio::write(stream_, b, ec); + net::write(stream_, b, ec); if(! check_ok(ec)) return bytes_transferred; bytes_transferred += n; @@ -801,7 +801,7 @@ write_some(bool fin, detail::fh_buffer fh_buf; detail::write< flat_static_buffer_base>(fh_buf, fh); - boost::asio::write(stream_, + net::write(stream_, buffers_cat(fh_buf.data(), b), ec); if(! check_ok(ec)) return bytes_transferred; @@ -825,7 +825,7 @@ async_write_some(bool fin, { static_assert(is_async_stream::value, "AsyncStream requirements not met"); - static_assert(boost::asio::is_const_buffer_sequence< + static_assert(net::is_const_buffer_sequence< ConstBufferSequence>::value, "ConstBufferSequence requirements not met"); BOOST_BEAST_HANDLER_INIT( @@ -847,7 +847,7 @@ write(ConstBufferSequence const& buffers) { static_assert(is_sync_stream::value, "SyncStream requirements not met"); - static_assert(boost::asio::is_const_buffer_sequence< + static_assert(net::is_const_buffer_sequence< ConstBufferSequence>::value, "ConstBufferSequence requirements not met"); error_code ec; @@ -865,7 +865,7 @@ write(ConstBufferSequence const& buffers, error_code& ec) { static_assert(is_sync_stream::value, "SyncStream requirements not met"); - static_assert(boost::asio::is_const_buffer_sequence< + static_assert(net::is_const_buffer_sequence< ConstBufferSequence>::value, "ConstBufferSequence requirements not met"); return write_some(true, buffers, ec); @@ -881,7 +881,7 @@ async_write( { static_assert(is_async_stream::value, "AsyncStream requirements not met"); - static_assert(boost::asio::is_const_buffer_sequence< + static_assert(net::is_const_buffer_sequence< ConstBufferSequence>::value, "ConstBufferSequence requirements not met"); BOOST_BEAST_HANDLER_INIT( diff --git a/include/boost/beast/websocket/rfc6455.hpp b/include/boost/beast/websocket/rfc6455.hpp index 921f8963..fa6b2196 100644 --- a/include/boost/beast/websocket/rfc6455.hpp +++ b/include/boost/beast/websocket/rfc6455.hpp @@ -36,7 +36,7 @@ namespace websocket { @par Example @code - void handle_connection(boost::asio::ip::tcp::socket& sock) + void handle_connection(net::ip::tcp::socket& sock) { boost::beast::flat_buffer buffer; boost::beast::http::request req; diff --git a/include/boost/beast/websocket/role.hpp b/include/boost/beast/websocket/role.hpp index d8869365..d8026f35 100644 --- a/include/boost/beast/websocket/role.hpp +++ b/include/boost/beast/websocket/role.hpp @@ -28,7 +28,7 @@ namespace websocket { performing the close operation. The default implementation for @ref stream when the next - layer type is a `boost::asio::ip::tcp::socket` behaves + layer type is a `net::ip::tcp::socket` behaves as follows: @li In the client role, a TCP/IP shutdown is sent after @@ -37,7 +37,7 @@ namespace websocket { @li In the server role, a TCP/IP shutdown is sent before reading all remaining data on the connection. - When the next layer type is a `boost::asio::ssl::stream`, + When the next layer type is a `net::ssl::stream`, the connection is closed by performing the SSL closing handshake corresponding to the role type, client or server. diff --git a/include/boost/beast/websocket/ssl.hpp b/include/boost/beast/websocket/ssl.hpp index d51921a4..3ff21008 100644 --- a/include/boost/beast/websocket/ssl.hpp +++ b/include/boost/beast/websocket/ssl.hpp @@ -19,13 +19,13 @@ namespace boost { namespace beast { namespace websocket { -/** Tear down a `boost::asio::ssl::stream`. +/** Tear down a `net::ssl::stream`. This tears down a connection. The implementation will call the overload of this function based on the `Stream` parameter used to consruct the socket. When `Stream` is a user defined - type, and not a `boost::asio::ip::tcp::socket` or any - `boost::asio::ssl::stream`, callers are responsible for + type, and not a `net::ip::tcp::socket` or any + `net::ssl::stream`, callers are responsible for providing a suitable overload of this function. @param role The role of the local endpoint @@ -38,16 +38,16 @@ template void teardown( role_type role, - boost::asio::ssl::stream& stream, + net::ssl::stream& stream, error_code& ec); -/** Start tearing down a `boost::asio::ssl::stream`. +/** Start tearing down a `net::ssl::stream`. This begins tearing down a connection asynchronously. The implementation will call the overload of this function based on the `Stream` parameter used to consruct the socket. When `Stream` is a user defined type, and not a - `boost::asio::ip::tcp::socket` or any `boost::asio::ssl::stream`, + `net::ip::tcp::socket` or any `net::ssl::stream`, callers are responsible for providing a suitable overload of this function. @@ -64,7 +64,7 @@ teardown( Regardless of whether the asynchronous operation completes immediately or not, the handler will not be invoked from within this function. Invocation of the handler will be performed in a - manner equivalent to using boost::asio::io_context::post(). + manner equivalent to using net::io_context::post(). */ template @@ -72,7 +72,7 @@ inline void async_teardown( role_type role, - boost::asio::ssl::stream& stream, + net::ssl::stream& stream, TeardownHandler&& handler); } // websocket diff --git a/include/boost/beast/websocket/stream.hpp b/include/boost/beast/websocket/stream.hpp index b5618ded..47b38b0e 100644 --- a/include/boost/beast/websocket/stream.hpp +++ b/include/boost/beast/websocket/stream.hpp @@ -1209,7 +1209,7 @@ public: Regardless of whether the asynchronous operation completes immediately or not, the handler will not be invoked from within this function. Invocation of the handler will be performed in a - manner equivalent to using `boost::asio::io_context::post`. + manner equivalent to using `net::io_context::post`. */ template BOOST_ASIO_INITFN_RESULT_TYPE( @@ -1261,7 +1261,7 @@ public: Regardless of whether the asynchronous operation completes immediately or not, the handler will not be invoked from within this function. Invocation of the handler will be performed in a - manner equivalent to using `boost::asio::io_context::post`. + manner equivalent to using `net::io_context::post`. */ template BOOST_ASIO_INITFN_RESULT_TYPE( @@ -1319,7 +1319,7 @@ public: Regardless of whether the asynchronous operation completes immediately or not, the handler will not be invoked from within this function. Invocation of the handler will be performed in a - manner equivalent to using `boost::asio::io_context::post`. + manner equivalent to using `net::io_context::post`. */ template BOOST_ASIO_INITFN_RESULT_TYPE( @@ -1381,7 +1381,7 @@ public: Regardless of whether the asynchronous operation completes immediately or not, the handler will not be invoked from within this function. Invocation of the handler will be performed in a - manner equivalent to using `boost::asio::io_context::post`. + manner equivalent to using `net::io_context::post`. */ template BOOST_ASIO_INITFN_RESULT_TYPE( @@ -1956,7 +1956,7 @@ public: Regardless of whether the asynchronous operation completes immediately or not, the handler will not be invoked from within this function. Invocation of the handler will be performed in a - manner equivalent to using `boost::asio::io_context::post`. + manner equivalent to using `net::io_context::post`. */ template BOOST_ASIO_INITFN_RESULT_TYPE( @@ -2017,7 +2017,7 @@ public: Regardless of whether the asynchronous operation completes immediately or not, the handler will not be invoked from within this function. Invocation of the handler will be performed in a - manner equivalent to using `boost::asio::io_context::post`. + manner equivalent to using `net::io_context::post`. */ template< class ResponseDecorator, @@ -2080,7 +2080,7 @@ public: Regardless of whether the asynchronous operation completes immediately or not, the handler will not be invoked from within this function. Invocation of the handler will be performed in a - manner equivalent to using `boost::asio::io_context::post`. + manner equivalent to using `net::io_context::post`. */ template< class ConstBufferSequence, @@ -2158,7 +2158,7 @@ public: Regardless of whether the asynchronous operation completes immediately or not, the handler will not be invoked from within this function. Invocation of the handler will be performed in a - manner equivalent to using `boost::asio::io_context::post`. + manner equivalent to using `net::io_context::post`. */ template< class ConstBufferSequence, @@ -2219,7 +2219,7 @@ public: Regardless of whether the asynchronous operation completes immediately or not, the handler will not be invoked from within this function. Invocation of the handler will be performed in a - manner equivalent to using `boost::asio::io_context::post`. + manner equivalent to using `net::io_context::post`. */ template< class Body, class Allocator, @@ -2282,7 +2282,7 @@ public: Regardless of whether the asynchronous operation completes immediately or not, the handler will not be invoked from within this function. Invocation of the handler will be performed in a - manner equivalent to using `boost::asio::io_context::post`. + manner equivalent to using `net::io_context::post`. */ template< class Body, class Allocator, @@ -2401,7 +2401,7 @@ public: Regardless of whether the asynchronous operation completes immediately or not, the handler will not be invoked from within this function. Invocation of the handler will be performed in a - manner equivalent to using `boost::asio::io_context::post`. + manner equivalent to using `net::io_context::post`. */ template BOOST_ASIO_INITFN_RESULT_TYPE( @@ -2464,7 +2464,7 @@ public: If a close frame is sent or received before the ping frame is sent, the completion handler will be called with the error - set to `boost::asio::error::operation_aborted`. + set to `net::error::operation_aborted`. @param payload The payload of the ping message, which may be empty. @@ -2479,7 +2479,7 @@ public: Regardless of whether the asynchronous operation completes immediately or not, the handler will not be invoked from within this function. Invocation of the handler will be performed in a - manner equivalent to using `boost::asio::io_context::post`. + manner equivalent to using `net::io_context::post`. */ template BOOST_ASIO_INITFN_RESULT_TYPE( @@ -2557,7 +2557,7 @@ public: If a close frame is sent or received before the pong frame is sent, the completion handler will be called with the error - set to `boost::asio::error::operation_aborted`. + set to `net::error::operation_aborted`. @param payload The payload of the pong message, which may be empty. @@ -2572,7 +2572,7 @@ public: Regardless of whether the asynchronous operation completes immediately or not, the handler will not be invoked from within this function. Invocation of the handler will be performed in a - manner equivalent to using `boost::asio::io_context::post`. + manner equivalent to using `net::io_context::post`. */ template BOOST_ASIO_INITFN_RESULT_TYPE( @@ -2731,7 +2731,7 @@ public: Regardless of whether the asynchronous operation completes immediately or not, the handler will not be invoked from within this function. Invocation of the handler will be performed in a - manner equivalent to using `boost::asio::io_context::post`. + manner equivalent to using `net::io_context::post`. */ template BOOST_ASIO_INITFN_RESULT_TYPE( @@ -2911,7 +2911,7 @@ public: Regardless of whether the asynchronous operation completes immediately or not, the handler will not be invoked from within this function. Invocation of the handler will be performed in a - manner equivalent to using `boost::asio::io_context::post`. + manner equivalent to using `net::io_context::post`. */ template BOOST_ASIO_INITFN_RESULT_TYPE( @@ -3084,7 +3084,7 @@ public: Regardless of whether the asynchronous operation completes immediately or not, the handler will not be invoked from within this function. Invocation of the handler will be performed in a - manner equivalent to using `boost::asio::io_context::post`. + manner equivalent to using `net::io_context::post`. */ template BOOST_ASIO_INITFN_RESULT_TYPE( @@ -3225,7 +3225,7 @@ public: Regardless of whether the asynchronous operation completes immediately or not, the handler will not be invoked from within this function. Invocation of the handler will be performed in a - manner equivalent to using `boost::asio::io_context::post`. + manner equivalent to using `net::io_context::post`. */ template< class ConstBufferSequence, @@ -3384,7 +3384,7 @@ private: { if(status_ != status::open) { - ec = boost::asio::error::operation_aborted; + ec = net::error::operation_aborted; return false; } ec.assign(0, ec.category()); diff --git a/include/boost/beast/websocket/teardown.hpp b/include/boost/beast/websocket/teardown.hpp index a255756d..1c373df5 100644 --- a/include/boost/beast/websocket/teardown.hpp +++ b/include/boost/beast/websocket/teardown.hpp @@ -25,8 +25,8 @@ namespace websocket { This tears down a connection. The implementation will call the overload of this function based on the `Socket` parameter used to consruct the socket. When `Socket` is a user defined - type, and not a `boost::asio::ip::tcp::socket` or any - `boost::asio::ssl::stream`, callers are responsible for + type, and not a `net::ip::tcp::socket` or any + `net::ssl::stream`, callers are responsible for providing a suitable overload of this function. @param role The role of the local endpoint @@ -61,7 +61,7 @@ teardown( The implementation will call the overload of this function based on the `Socket` parameter used to consruct the socket. When `Stream` is a user defined type, and not a - `boost::asio::ip::tcp::socket` or any `boost::asio::ssl::stream`, + `net::ip::tcp::socket` or any `net::ssl::stream`, callers are responsible for providing a suitable overload of this function. @@ -79,7 +79,7 @@ teardown( Regardless of whether the asynchronous operation completes immediately or not, the handler will not be invoked from within this function. Invocation of the handler will be performed in a - manner equivalent to using boost::asio::io_context::post(). + manner equivalent to using net::io_context::post(). */ template< @@ -110,13 +110,13 @@ async_teardown( namespace websocket { -/** Tear down a `boost::asio::ip::tcp::socket`. +/** Tear down a `net::ip::tcp::socket`. This tears down a connection. The implementation will call the overload of this function based on the `Stream` parameter used to consruct the socket. When `Stream` is a user defined - type, and not a `boost::asio::ip::tcp::socket` or any - `boost::asio::ssl::stream`, callers are responsible for + type, and not a `net::ip::tcp::socket` or any + `net::ssl::stream`, callers are responsible for providing a suitable overload of this function. @param role The role of the local endpoint @@ -128,16 +128,16 @@ namespace websocket { void teardown( role_type role, - boost::asio::ip::tcp::socket& socket, + net::ip::tcp::socket& socket, error_code& ec); -/** Start tearing down a `boost::asio::ip::tcp::socket`. +/** Start tearing down a `net::ip::tcp::socket`. This begins tearing down a connection asynchronously. The implementation will call the overload of this function based on the `Stream` parameter used to consruct the socket. When `Stream` is a user defined type, and not a - `boost::asio::ip::tcp::socket` or any `boost::asio::ssl::stream`, + `net::ip::tcp::socket` or any `net::ssl::stream`, callers are responsible for providing a suitable overload of this function. @@ -155,14 +155,14 @@ teardown( Regardless of whether the asynchronous operation completes immediately or not, the handler will not be invoked from within this function. Invocation of the handler will be performed in a - manner equivalent to using boost::asio::io_context::post(). + manner equivalent to using net::io_context::post(). */ template void async_teardown( role_type role, - boost::asio::ip::tcp::socket& socket, + net::ip::tcp::socket& socket, TeardownHandler&& handler); } // websocket diff --git a/test/beast/core/bind_handler.cpp b/test/beast/core/bind_handler.cpp index 8fe5c088..d6f799f5 100644 --- a/test/beast/core/bind_handler.cpp +++ b/test/beast/core/bind_handler.cpp @@ -103,12 +103,12 @@ public: // make sure things compile, also can set a // breakpoint in asio_handler_invoke to make sure // it is instantiated. - boost::asio::io_context ioc; - boost::asio::strand< - boost::asio::io_context::executor_type> s{ + net::io_context ioc; + net::strand< + net::io_context::executor_type> s{ ioc.get_executor()}; test::stream ts{ioc}; - boost::asio::post(s, + net::post(s, bind_handler(copyable{}, 42)); } } @@ -174,12 +174,12 @@ public: // make sure things compile, also can set a // breakpoint in asio_handler_invoke to make sure // it is instantiated. - boost::asio::io_context ioc; - boost::asio::strand< - boost::asio::io_context::executor_type> s{ + net::io_context ioc; + net::strand< + net::io_context::executor_type> s{ ioc.get_executor()}; test::stream ts{ioc}; - boost::asio::post(s, + net::post(s, bind_front_handler(copyable{}, 42)); } } diff --git a/test/beast/core/buffer.cpp b/test/beast/core/buffer.cpp index 542c5881..74aabf2a 100644 --- a/test/beast/core/buffer.cpp +++ b/test/beast/core/buffer.cpp @@ -21,7 +21,7 @@ namespace boost { namespace beast { // VFALCO No idea why boost::system::errc::message_size fails -// to compile, so we use boost::asio::error::eof instead. +// to compile, so we use net::error::eof instead. // class buffer_test : public beast::unit_test::suite { @@ -35,17 +35,17 @@ public: DynamicBuffer b(32); detail::dynamic_buffer_prepare(b, 20, ec, //boost::system::errc::message_size); - boost::asio::error::eof); + net::error::eof); BEAST_EXPECTS(! ec, ec.message()); b.commit(20); auto const result = detail::dynamic_buffer_prepare(b, 20, ec, //boost::system::errc::message_size); - boost::asio::error::eof); + net::error::eof); BEAST_EXPECT(result == boost::none); BEAST_EXPECTS( //ec == boost::system::errc::message_size, - ec == boost::asio::error::eof, ec.message()); + ec == net::error::eof, ec.message()); #else fail("exceptions disabled", __FILE__, __LINE__); #endif @@ -59,17 +59,17 @@ public: DynamicBuffer b(32); detail::dynamic_buffer_prepare_noexcept(b, 20, ec, //boost::system::errc::message_size); - boost::asio::error::eof); + net::error::eof); BEAST_EXPECTS(! ec, ec.message()); b.commit(20); auto const result = detail::dynamic_buffer_prepare_noexcept(b, 20, ec, //boost::system::errc::message_size); - boost::asio::error::eof); + net::error::eof); BEAST_EXPECT(result == boost::none); BEAST_EXPECTS( //ec == boost::system::errc::message_size, - ec == boost::asio::error::eof, ec.message()); + ec == net::error::eof, ec.message()); } void diff --git a/test/beast/core/buffer_test.hpp b/test/beast/core/buffer_test.hpp index ccd26582..8a8933dc 100644 --- a/test/beast/core/buffer_test.hpp +++ b/test/beast/core/buffer_test.hpp @@ -28,14 +28,14 @@ template void write_buffer(DynamicBuffer& b, string_view s) { - b.commit(boost::asio::buffer_copy( - b.prepare(s.size()), boost::asio::buffer( + b.commit(net::buffer_copy( + b.prepare(s.size()), net::buffer( s.data(), s.size()))); } template typename std::enable_if< - boost::asio::is_const_buffer_sequence::value, + net::is_const_buffer_sequence::value, std::size_t>::type buffer_count(ConstBufferSequence const& buffers) { @@ -44,7 +44,7 @@ buffer_count(ConstBufferSequence const& buffers) template typename std::enable_if< - boost::asio::is_const_buffer_sequence::value, + net::is_const_buffer_sequence::value, std::size_t>::type size_pre(ConstBufferSequence const& buffers) { @@ -55,7 +55,7 @@ size_pre(ConstBufferSequence const& buffers) typename ConstBufferSequence::const_iterator it1(it0); typename ConstBufferSequence::const_iterator it2; it2 = it1; - n += boost::asio::buffer_size(*it2); + n += net::buffer_size(*it2); it = std::move(it2); } return n; @@ -63,31 +63,31 @@ size_pre(ConstBufferSequence const& buffers) template typename std::enable_if< - boost::asio::is_const_buffer_sequence::value, + net::is_const_buffer_sequence::value, std::size_t>::type size_post(ConstBufferSequence const& buffers) { std::size_t n = 0; for(auto it = buffers.begin(); it != buffers.end(); it++) - n += boost::asio::buffer_size(*it); + n += net::buffer_size(*it); return n; } template typename std::enable_if< - boost::asio::is_const_buffer_sequence::value, + net::is_const_buffer_sequence::value, std::size_t>::type size_rev_pre(ConstBufferSequence const& buffers) { std::size_t n = 0; for(auto it = buffers.end(); it != buffers.begin();) - n += boost::asio::buffer_size(*--it); + n += net::buffer_size(*--it); return n; } template typename std::enable_if< - boost::asio::is_const_buffer_sequence::value, + net::is_const_buffer_sequence::value, std::size_t>::type size_rev_post(ConstBufferSequence const& buffers) { @@ -95,7 +95,7 @@ size_rev_post(ConstBufferSequence const& buffers) for(auto it = buffers.end(); it != buffers.begin();) { it--; - n += boost::asio::buffer_size(*it); + n += net::buffer_size(*it); } return n; } diff --git a/test/beast/core/buffered_read_stream.cpp b/test/beast/core/buffered_read_stream.cpp index bb1e7ef4..12f52dcb 100644 --- a/test/beast/core/buffered_read_stream.cpp +++ b/test/beast/core/buffered_read_stream.cpp @@ -33,7 +33,7 @@ class buffered_read_stream_test public: void testSpecialMembers() { - boost::asio::io_context ioc; + net::io_context ioc; { buffered_read_stream srs(ioc); buffered_read_stream srs2(std::move(srs)); @@ -55,7 +55,7 @@ public: std::size_t n_ = 0; std::size_t cap_; unit_test::suite& suite_; - boost::asio::io_context& ioc_; + net::io_context& ioc_; boost::optional ts_; boost::optional fc_; boost::optionalbuffer().commit(buffer_copy( brs_->buffer().prepare(5), buffer("Hello", 5))); - boost::asio::async_read(*brs_, + net::async_read(*brs_, buffer(&s_[0], s_.size()), std::bind( &loop::on_read, @@ -124,8 +124,8 @@ public: void testRead(yield_context do_yield) { - using boost::asio::buffer; - using boost::asio::buffer_copy; + using net::buffer; + using net::buffer_copy; static std::size_t constexpr limit = 100; std::size_t n; std::string s; @@ -140,7 +140,7 @@ public: srs.buffer().commit(buffer_copy( srs.buffer().prepare(5), buffer("Hello", 5))); error_code ec = test::error::test_failure; - boost::asio::read(srs, buffer(&s[0], s.size()), ec); + net::read(srs, buffer(&s[0], s.size()), ec); if(! ec) { BEAST_EXPECT(s == "Hello, world!"); @@ -159,7 +159,7 @@ public: srs.buffer().commit(buffer_copy( srs.buffer().prepare(5), buffer("Hello", 5))); error_code ec = test::error::test_failure; - boost::asio::read(srs, buffer(&s[0], s.size()), ec); + net::read(srs, buffer(&s[0], s.size()), ec); if(! ec) { BEAST_EXPECT(s == "Hello, world!"); @@ -177,7 +177,7 @@ public: srs.buffer().commit(buffer_copy( srs.buffer().prepare(5), buffer("Hello", 5))); error_code ec = test::error::test_failure; - boost::asio::async_read( + net::async_read( srs, buffer(&s[0], s.size()), do_yield[ec]); if(! ec) { @@ -197,7 +197,7 @@ public: srs.buffer().commit(buffer_copy( srs.buffer().prepare(5), buffer("Hello", 5))); error_code ec = test::error::test_failure; - boost::asio::async_read( + net::async_read( srs, buffer(&s[0], s.size()), do_yield[ec]); if(! ec) { @@ -223,15 +223,15 @@ public: // make sure things compile, also can set a // breakpoint in asio_handler_invoke to make sure // it is instantiated. - boost::asio::io_context ioc; - boost::asio::strand< - boost::asio::io_context::executor_type> s( + net::io_context ioc; + net::strand< + net::io_context::executor_type> s( ioc.get_executor()); test::stream ts{ioc}; buffered_read_stream< test::stream&, multi_buffer> brs(ts); - brs.async_read_some(boost::asio::mutable_buffer{}, - boost::asio::bind_executor( + brs.async_read_some(net::mutable_buffer{}, + net::bind_executor( s, copyable_handler{})); } diff --git a/test/beast/core/buffers_adapter.cpp b/test/beast/core/buffers_adapter.cpp index b96f617e..83f7f720 100644 --- a/test/beast/core/buffers_adapter.cpp +++ b/test/beast/core/buffers_adapter.cpp @@ -26,10 +26,10 @@ class buffers_adapter_test : public unit_test::suite public: void testBuffersAdapter() { - using boost::asio::buffer; - using boost::asio::buffer_size; - using boost::asio::const_buffer; - using boost::asio::mutable_buffer; + using net::buffer; + using net::buffer_size; + using net::const_buffer; + using net::mutable_buffer; char buf[12]; std::string const s = "Hello, world"; BEAST_EXPECT(s.size() == sizeof(buf)); @@ -141,9 +141,9 @@ public: } void testCommit() { - using boost::asio::buffer_size; + using net::buffer_size; { - using sb_type = boost::asio::streambuf; + using sb_type = net::streambuf; sb_type b; buffers_adapter< sb_type::mutable_buffers_type> ba(b.prepare(3)); @@ -171,7 +171,7 @@ public: void testIssue386() { - using type = boost::asio::streambuf; + using type = net::streambuf; type buffer; buffers_adapter< type::mutable_buffers_type> ba{buffer.prepare(512)}; diff --git a/test/beast/core/buffers_cat.cpp b/test/beast/core/buffers_cat.cpp index 3800072c..e0b33d45 100644 --- a/test/beast/core/buffers_cat.cpp +++ b/test/beast/core/buffers_cat.cpp @@ -39,7 +39,7 @@ public: std::size_t bsize1(ConstBufferSequence const& bs) { - using boost::asio::buffer_size; + using net::buffer_size; std::size_t n = 0; for(auto it = bs.begin(); it != bs.end(); ++it) n += buffer_size(*it); @@ -51,7 +51,7 @@ public: std::size_t bsize2(ConstBufferSequence const& bs) { - using boost::asio::buffer_size; + using net::buffer_size; std::size_t n = 0; for(auto it = bs.begin(); it != bs.end(); it++) n += buffer_size(*it); @@ -63,7 +63,7 @@ public: std::size_t bsize3(ConstBufferSequence const& bs) { - using boost::asio::buffer_size; + using net::buffer_size; std::size_t n = 0; for(auto it = bs.end(); it != bs.begin();) n += buffer_size(*--it); @@ -75,7 +75,7 @@ public: std::size_t bsize4(ConstBufferSequence const& bs) { - using boost::asio::buffer_size; + using net::buffer_size; std::size_t n = 0; for(auto it = bs.end(); it != bs.begin();) { @@ -87,8 +87,8 @@ public: void testBufferCat() { - using boost::asio::buffer_size; - using boost::asio::const_buffer; + using net::buffer_size; + using net::const_buffer; char buf[10]; std::list b1; std::vector b2{ @@ -117,7 +117,7 @@ public: decltype(bs) bs2(bs); auto bs3(std::move(bs)); { - boost::asio::streambuf sb1, sb2; + net::streambuf sb1, sb2; BEAST_EXPECT(buffer_size(buffers_cat( sb1.prepare(5), sb2.prepare(7))) == 12); sb1.commit(5); @@ -137,8 +137,8 @@ public: void testIterators() { - using boost::asio::buffer_size; - using boost::asio::const_buffer; + using net::buffer_size; + using net::const_buffer; char buf[9]; std::vector b1{ const_buffer{buf+0, 1}, @@ -222,8 +222,8 @@ public: { using boost::beast::buffers_cat; using boost::beast::buffers_suffix; - using boost::asio::buffer; - using boost::asio::const_buffer; + using net::buffer; + using net::const_buffer; char out[64]; std::array buffers{ @@ -231,7 +231,7 @@ public: std::size_t i = 3; buffers_suffix> cb(buffers); cb.consume(i); - boost::asio::buffer_copy( + net::buffer_copy( buffer(out), buffers_cat(cb, cb)); } @@ -242,9 +242,9 @@ public: void testGccWarning2() { - using boost::asio::buffer; - using boost::asio::buffer_copy; - using boost::asio::const_buffer; + using net::buffer; + using net::buffer_copy; + using net::const_buffer; char out[64]; const_buffer buffers("Hello, world!", 13); @@ -259,8 +259,8 @@ public: void test_empty_buffer_sequences() { - using boost::asio::buffer_size; - using boost::asio::const_buffer; + using net::buffer_size; + using net::const_buffer; std::vector v1; std::vector v2; BEAST_EXPECT(buffer_size(buffers_cat(v1, v2)) == 0); @@ -268,9 +268,9 @@ public: void run() override { - using boost::asio::const_buffer; - using boost::asio::const_buffer; - using boost::asio::mutable_buffer; + using net::const_buffer; + using net::const_buffer; + using net::mutable_buffer; struct user_defined : mutable_buffer { }; diff --git a/test/beast/core/buffers_prefix.cpp b/test/beast/core/buffers_prefix.cpp index ce1e06fe..4614eb6d 100644 --- a/test/beast/core/buffers_prefix.cpp +++ b/test/beast/core/buffers_prefix.cpp @@ -21,19 +21,19 @@ namespace boost { namespace beast { BOOST_STATIC_ASSERT( - std::is_same()))>::value); + std::declval()))>::value); BOOST_STATIC_ASSERT( - boost::asio::is_const_buffer_sequence()))>::value); + std::declval()))>::value); BOOST_STATIC_ASSERT( - std::is_same()))>::value); + std::declval()))>::value); class buffers_prefix_test : public beast::unit_test::suite { @@ -43,7 +43,7 @@ public: std::size_t bsize1(ConstBufferSequence const& bs) { - using boost::asio::buffer_size; + using net::buffer_size; std::size_t n = 0; for(auto it = bs.begin(); it != bs.end(); ++it) n += buffer_size(*it); @@ -55,7 +55,7 @@ public: std::size_t bsize2(ConstBufferSequence const& bs) { - using boost::asio::buffer_size; + using net::buffer_size; std::size_t n = 0; for(auto it = bs.begin(); it != bs.end(); it++) n += buffer_size(*it); @@ -67,7 +67,7 @@ public: std::size_t bsize3(ConstBufferSequence const& bs) { - using boost::asio::buffer_size; + using net::buffer_size; std::size_t n = 0; for(auto it = bs.end(); it != bs.begin();) n += buffer_size(*--it); @@ -79,7 +79,7 @@ public: std::size_t bsize4(ConstBufferSequence const& bs) { - using boost::asio::buffer_size; + using net::buffer_size; std::size_t n = 0; for(auto it = bs.end(); it != bs.begin();) { @@ -92,7 +92,7 @@ public: template void testMatrix() { - using boost::asio::buffer_size; + using net::buffer_size; std::string s = "Hello, world"; BEAST_EXPECT(s.size() == 12); for(std::size_t x = 1; x < 4; ++x) { @@ -121,9 +121,9 @@ public: void testEmptyBuffers() { - using boost::asio::buffer_copy; - using boost::asio::buffer_size; - using boost::asio::mutable_buffer; + using net::buffer_copy; + using net::buffer_size; + using net::mutable_buffer; auto pb0 = buffers_prefix(0, mutable_buffer{}); BEAST_EXPECT(buffer_size(pb0) == 0); auto pb1 = buffers_prefix(1, mutable_buffer{}); @@ -145,8 +145,8 @@ public: void testIterator() { - using boost::asio::buffer_size; - using boost::asio::const_buffer; + using net::buffer_size; + using net::const_buffer; char b[3]; std::array bs{{ const_buffer{&b[0], 1}, @@ -161,8 +161,8 @@ public: void run() override { - testMatrix(); - testMatrix(); + testMatrix(); + testMatrix(); testEmptyBuffers(); testIterator(); } diff --git a/test/beast/core/buffers_suffix.cpp b/test/beast/core/buffers_suffix.cpp index 85587d4e..e7e92d39 100644 --- a/test/beast/core/buffers_suffix.cpp +++ b/test/beast/core/buffers_suffix.cpp @@ -58,10 +58,10 @@ public: { char buf[12]; buffers_suffix< - boost::asio::const_buffer> cb1{ + net::const_buffer> cb1{ boost::in_place_init, buf, sizeof(buf)}; buffers_suffix< - boost::asio::const_buffer> cb2{ + net::const_buffer> cb2{ boost::in_place_init, nullptr, 0}; cb2 = cb1; cb1 = std::move(cb2); @@ -71,8 +71,8 @@ public: testMatrix() { using namespace test; - using boost::asio::buffer; - using boost::asio::const_buffer; + using net::buffer; + using net::const_buffer; char buf[12]; std::string const s = "Hello, world"; BEAST_EXPECT(s.size() == sizeof(buf)); @@ -116,11 +116,11 @@ public: testDefaultCtor() { using namespace test; - class test_buffer : public boost::asio::const_buffer + class test_buffer : public net::const_buffer { public: test_buffer() - : boost::asio::const_buffer("\r\n", 2) + : net::const_buffer("\r\n", 2) { } }; @@ -134,20 +134,20 @@ public: { using namespace test; buffers_suffix> cb( + net::const_buffer, + net::const_buffer>> cb( boost::in_place_init, - boost::asio::const_buffer("\r", 1), - boost::asio::const_buffer("\n", 1)); + net::const_buffer("\r", 1), + net::const_buffer("\n", 1)); BEAST_EXPECT(buffers_to_string(cb) == "\r\n"); } void testEmptyBuffers() { - using boost::asio::buffer_copy; - using boost::asio::buffer_size; - using boost::asio::mutable_buffer; + using net::buffer_copy; + using net::buffer_size; + using net::mutable_buffer; buffers_suffix cb( mutable_buffer{}); BEAST_EXPECT(buffer_size(cb) == 0); @@ -159,7 +159,7 @@ public: void testIterator() { - using boost::asio::const_buffer; + using net::const_buffer; std::array ba; buffers_suffix cb(ba); std::size_t n = 0; diff --git a/test/beast/core/flat_buffer.cpp b/test/beast/core/flat_buffer.cpp index 719f9b55..b400b20d 100644 --- a/test/beast/core/flat_buffer.cpp +++ b/test/beast/core/flat_buffer.cpp @@ -28,16 +28,16 @@ class flat_buffer_test : public beast::unit_test::suite { public: BOOST_STATIC_ASSERT( - boost::asio::is_dynamic_buffer< + net::is_dynamic_buffer< flat_buffer>::value); BOOST_STATIC_ASSERT( - boost::asio::is_const_buffer_sequence< + net::is_const_buffer_sequence< flat_buffer::const_buffers_type>::value); BOOST_STATIC_ASSERT( - boost::asio::is_mutable_buffer_sequence< + net::is_mutable_buffer_sequence< flat_buffer::mutable_data_type>::value); BOOST_STATIC_ASSERT( - boost::asio::is_mutable_buffer_sequence< + net::is_mutable_buffer_sequence< flat_buffer::mutable_buffers_type>::value); BOOST_STATIC_ASSERT(std::is_convertible< flat_buffer::mutable_data_type, @@ -51,21 +51,21 @@ public: DynamicBuffer const& cb = b; ostream(b) << "Hello"; BOOST_STATIC_ASSERT( - boost::asio::is_const_buffer_sequence< + net::is_const_buffer_sequence< decltype(cb.data())>::value && - ! boost::asio::is_mutable_buffer_sequence< + ! net::is_mutable_buffer_sequence< decltype(cb.data())>::value); BOOST_STATIC_ASSERT( - boost::asio::is_const_buffer_sequence< + net::is_const_buffer_sequence< decltype(cb.cdata())>::value && - ! boost::asio::is_mutable_buffer_sequence< + ! net::is_mutable_buffer_sequence< decltype(cb.cdata())>::value); BOOST_STATIC_ASSERT( - boost::asio::is_mutable_buffer_sequence< + net::is_mutable_buffer_sequence< decltype(b.data())>::value); std::for_each( - boost::asio::buffers_iterator::begin(b.data()), - boost::asio::buffers_iterator::end(b.data()), + net::buffers_iterator::begin(b.data()), + net::buffers_iterator::end(b.data()), [](char& c) { c = static_cast(std::toupper(c)); diff --git a/test/beast/core/flat_static_buffer.cpp b/test/beast/core/flat_static_buffer.cpp index e9162b5e..bf0c9b12 100644 --- a/test/beast/core/flat_static_buffer.cpp +++ b/test/beast/core/flat_static_buffer.cpp @@ -27,16 +27,16 @@ class flat_static_buffer_test : public beast::unit_test::suite { public: BOOST_STATIC_ASSERT( - boost::asio::is_dynamic_buffer< + net::is_dynamic_buffer< flat_static_buffer_base>::value); BOOST_STATIC_ASSERT( - boost::asio::is_const_buffer_sequence< + net::is_const_buffer_sequence< flat_static_buffer_base::const_buffers_type>::value); BOOST_STATIC_ASSERT( - boost::asio::is_mutable_buffer_sequence< + net::is_mutable_buffer_sequence< flat_static_buffer_base::mutable_data_type>::value); BOOST_STATIC_ASSERT( - boost::asio::is_mutable_buffer_sequence< + net::is_mutable_buffer_sequence< flat_static_buffer_base::mutable_buffers_type>::value); BOOST_STATIC_ASSERT(std::is_convertible< flat_static_buffer_base::mutable_data_type, @@ -50,21 +50,21 @@ public: DynamicBuffer const& cb = b; ostream(b) << "Hello"; BOOST_STATIC_ASSERT( - boost::asio::is_const_buffer_sequence< + net::is_const_buffer_sequence< decltype(cb.data())>::value && - ! boost::asio::is_mutable_buffer_sequence< + ! net::is_mutable_buffer_sequence< decltype(cb.data())>::value); BOOST_STATIC_ASSERT( - boost::asio::is_const_buffer_sequence< + net::is_const_buffer_sequence< decltype(cb.cdata())>::value && - ! boost::asio::is_mutable_buffer_sequence< + ! net::is_mutable_buffer_sequence< decltype(cb.cdata())>::value); BOOST_STATIC_ASSERT( - boost::asio::is_mutable_buffer_sequence< + net::is_mutable_buffer_sequence< decltype(b.data())>::value); std::for_each( - boost::asio::buffers_iterator::begin(b.data()), - boost::asio::buffers_iterator::end(b.data()), + net::buffers_iterator::begin(b.data()), + net::buffers_iterator::end(b.data()), [](char& c) { c = static_cast(std::toupper(c)); @@ -77,8 +77,8 @@ public: testStaticBuffer() { using namespace test; - using boost::asio::buffer; - using boost::asio::buffer_size; + using net::buffer; + using net::buffer_size; char buf[12]; std::string const s = "Hello, world"; BEAST_EXPECT(s.size() == sizeof(buf)); diff --git a/test/beast/core/multi_buffer.cpp b/test/beast/core/multi_buffer.cpp index ae44042f..ebe5dd40 100644 --- a/test/beast/core/multi_buffer.cpp +++ b/test/beast/core/multi_buffer.cpp @@ -32,16 +32,16 @@ class multi_buffer_test : public beast::unit_test::suite { public: BOOST_STATIC_ASSERT( - boost::asio::is_dynamic_buffer< + net::is_dynamic_buffer< multi_buffer>::value); BOOST_STATIC_ASSERT( - boost::asio::is_const_buffer_sequence< + net::is_const_buffer_sequence< multi_buffer::const_buffers_type>::value); BOOST_STATIC_ASSERT( - boost::asio::is_mutable_buffer_sequence< + net::is_mutable_buffer_sequence< multi_buffer::mutable_data_type>::value); BOOST_STATIC_ASSERT( - boost::asio::is_mutable_buffer_sequence< + net::is_mutable_buffer_sequence< multi_buffer::mutable_buffers_type>::value); BOOST_STATIC_ASSERT(std::is_convertible< multi_buffer::mutable_data_type, @@ -83,22 +83,22 @@ public: DynamicBuffer const& cb = b; ostream(b) << "Hello"; BOOST_STATIC_ASSERT( - boost::asio::is_const_buffer_sequence< + net::is_const_buffer_sequence< decltype(cb.data())>::value && - ! boost::asio::is_mutable_buffer_sequence< + ! net::is_mutable_buffer_sequence< decltype(cb.data())>::value); BOOST_STATIC_ASSERT( - boost::asio::is_const_buffer_sequence< + net::is_const_buffer_sequence< decltype(cb.cdata())>::value && - ! boost::asio::is_mutable_buffer_sequence< + ! net::is_mutable_buffer_sequence< decltype(cb.cdata())>::value); BOOST_STATIC_ASSERT( - boost::asio::is_mutable_buffer_sequence< + net::is_mutable_buffer_sequence< decltype(b.data())>::value); std::for_each( - boost::asio::buffers_iterator::begin(b.data()), - boost::asio::buffers_iterator::end(b.data()), + net::buffers_iterator::begin(b.data()), + net::buffers_iterator::end(b.data()), [](char& c) { c = static_cast(std::toupper(c)); @@ -111,7 +111,7 @@ public: testMatrix1() { using namespace test; - using boost::asio::buffer; + using net::buffer; std::string const s = "Hello, world"; BEAST_EXPECT(s.size() == 12); for(std::size_t i = 1; i < 12; ++i) { @@ -153,8 +153,8 @@ public: testMatrix2() { using namespace test; - using boost::asio::buffer; - using boost::asio::buffer_size; + using net::buffer; + using net::buffer_size; std::string const s = "Hello, world"; BEAST_EXPECT(s.size() == 12); for(std::size_t i = 1; i < 12; ++i) { @@ -248,7 +248,7 @@ public: void testIterators() { - using boost::asio::buffer_size; + using net::buffer_size; multi_buffer b; b.prepare(1); b.commit(1); diff --git a/test/beast/core/read_size.cpp b/test/beast/core/read_size.cpp index 0b9a90c9..163689e0 100644 --- a/test/beast/core/read_size.cpp +++ b/test/beast/core/read_size.cpp @@ -40,7 +40,7 @@ public: check>(); check(); check>(); - check(); + check(); } }; diff --git a/test/beast/core/static_buffer.cpp b/test/beast/core/static_buffer.cpp index 1a26c168..1d4d3ef1 100644 --- a/test/beast/core/static_buffer.cpp +++ b/test/beast/core/static_buffer.cpp @@ -24,22 +24,22 @@ namespace boost { namespace beast { BOOST_STATIC_ASSERT( - boost::asio::is_dynamic_buffer::value); + net::is_dynamic_buffer::value); class static_buffer_test : public beast::unit_test::suite { public: BOOST_STATIC_ASSERT( - boost::asio::is_dynamic_buffer< + net::is_dynamic_buffer< static_buffer_base>::value); BOOST_STATIC_ASSERT( - boost::asio::is_const_buffer_sequence< + net::is_const_buffer_sequence< static_buffer_base::const_buffers_type>::value); BOOST_STATIC_ASSERT( - boost::asio::is_mutable_buffer_sequence< + net::is_mutable_buffer_sequence< static_buffer_base::mutable_data_type>::value); BOOST_STATIC_ASSERT( - boost::asio::is_mutable_buffer_sequence< + net::is_mutable_buffer_sequence< static_buffer_base::mutable_buffers_type>::value); BOOST_STATIC_ASSERT(std::is_convertible< static_buffer_base::mutable_data_type, @@ -53,21 +53,21 @@ public: DynamicBuffer const& cb = b; ostream(b) << "Hello"; BOOST_STATIC_ASSERT( - boost::asio::is_const_buffer_sequence< + net::is_const_buffer_sequence< decltype(cb.data())>::value && - ! boost::asio::is_mutable_buffer_sequence< + ! net::is_mutable_buffer_sequence< decltype(cb.data())>::value); BOOST_STATIC_ASSERT( - boost::asio::is_const_buffer_sequence< + net::is_const_buffer_sequence< decltype(cb.cdata())>::value && - ! boost::asio::is_mutable_buffer_sequence< + ! net::is_mutable_buffer_sequence< decltype(cb.cdata())>::value); BOOST_STATIC_ASSERT( - boost::asio::is_mutable_buffer_sequence< + net::is_mutable_buffer_sequence< decltype(b.data())>::value); std::for_each( - boost::asio::buffers_iterator::begin(b.data()), - boost::asio::buffers_iterator::end(b.data()), + net::buffers_iterator::begin(b.data()), + net::buffers_iterator::end(b.data()), [](char& c) { c = static_cast(std::toupper(c)); @@ -80,8 +80,8 @@ public: testStaticBuffer() { using namespace test; - using boost::asio::buffer; - using boost::asio::buffer_size; + using net::buffer; + using net::buffer_size; char buf[12]; std::string const s = "Hello, world"; BEAST_EXPECT(s.size() == sizeof(buf)); diff --git a/test/beast/core/type_traits.cpp b/test/beast/core/type_traits.cpp index 45ceb23e..3f1a9905 100644 --- a/test/beast/core/type_traits.cpp +++ b/test/beast/core/type_traits.cpp @@ -142,7 +142,7 @@ BOOST_STATIC_ASSERT(! is_completion_handler::value); namespace { -using stream_type = boost::asio::ip::tcp::socket; +using stream_type = net::ip::tcp::socket; struct not_a_stream { diff --git a/test/beast/experimental/flat_stream.cpp b/test/beast/experimental/flat_stream.cpp index 0eaeab2f..ccf8f51b 100644 --- a/test/beast/experimental/flat_stream.cpp +++ b/test/beast/experimental/flat_stream.cpp @@ -34,7 +34,7 @@ public: unsigned long count, bool copy) { - std::vector v; + std::vector v; v.reserve(v0.size()); for(auto const n : v0) v.emplace_back("", n); @@ -69,7 +69,7 @@ public: { error_code ec; test::ws_echo_server es{log}; - boost::asio::io_context ioc; + net::io_context ioc; websocket::stream> ws{ioc}; ws.next_layer().next_layer().connect(es.stream()); ws.handshake("localhost", "/", ec); @@ -79,7 +79,7 @@ public: } { test::ws_echo_server es{log}; - boost::asio::io_context ioc; + net::io_context ioc; websocket::stream> ws{ioc}; ws.next_layer().next_layer().connect(es.stream()); ws.async_handshake("localhost", "/", diff --git a/test/beast/experimental/icy_stream.cpp b/test/beast/experimental/icy_stream.cpp index 28bd1e9d..7af5be44 100644 --- a/test/beast/experimental/icy_stream.cpp +++ b/test/beast/experimental/icy_stream.cpp @@ -30,8 +30,8 @@ public: void doMatrix(string_view in, string_view out) { - using boost::asio::mutable_buffer; - boost::asio::io_context ioc; + using net::mutable_buffer; + net::io_context ioc; auto len = out.size() + 8; std::unique_ptr p(new char[len]); for(std::size_t i = 1; i < len; ++i) @@ -62,7 +62,7 @@ public: break; } if(! BEAST_EXPECTS( - ec == boost::asio::error::eof, ec.message())) + ec == net::error::eof, ec.message())) continue; auto const s = buffers_to_string(ba.data()); BEAST_EXPECTS(s == out, s); @@ -93,7 +93,7 @@ public: break; } if(! BEAST_EXPECTS( - ec == boost::asio::error::eof, ec.message())) + ec == net::error::eof, ec.message())) continue; auto const s = buffers_to_string(ba.data()); if(! BEAST_EXPECTS(s == out, s)) diff --git a/test/beast/experimental/timeout_service.cpp b/test/beast/experimental/timeout_service.cpp index 70517eae..f27d2939 100644 --- a/test/beast/experimental/timeout_service.cpp +++ b/test/beast/experimental/timeout_service.cpp @@ -22,7 +22,7 @@ public: void run() override { - boost::asio::io_context ctx; + net::io_context ctx; set_timeout_service_options(ctx, std::chrono::seconds(1)); pass(); diff --git a/test/beast/experimental/timeout_socket.cpp b/test/beast/experimental/timeout_socket.cpp index 30b8f8d9..21d6be92 100644 --- a/test/beast/experimental/timeout_socket.cpp +++ b/test/beast/experimental/timeout_socket.cpp @@ -28,21 +28,21 @@ public: class server { std::ostream& log_; - boost::asio::io_context ioc_; - boost::asio::ip::tcp::acceptor acceptor_; - boost::asio::ip::tcp::socket socket_; + net::io_context ioc_; + net::ip::tcp::acceptor acceptor_; + net::ip::tcp::socket socket_; std::thread t_; void fail(error_code ec, string_view what) { - if(ec != boost::asio::error::operation_aborted) + if(ec != net::error::operation_aborted) log_ << what << ": " << ec.message() << "\n"; } public: server( - boost::asio::ip::tcp::endpoint ep, + net::ip::tcp::endpoint ep, std::ostream& log) : log_(log) , ioc_(1) @@ -59,7 +59,7 @@ public: } acceptor_.set_option( - boost::asio::socket_base::reuse_address(true), ec); + net::socket_base::reuse_address(true), ec); if(ec) { fail(ec, "set_option"); @@ -74,7 +74,7 @@ public: } acceptor_.listen( - boost::asio::socket_base::max_listen_connections, ec); + net::socket_base::max_listen_connections, ec); if(ec) { fail(ec, "listen"); @@ -97,11 +97,11 @@ public: class session : public std::enable_shared_from_this { - boost::asio::ip::tcp::socket socket_; + net::ip::tcp::socket socket_; public: session( - boost::asio::ip::tcp::socket sock, + net::ip::tcp::socket sock, std::ostream&) : socket_(std::move(sock)) { @@ -111,7 +111,7 @@ public: run() { socket_.async_wait( - boost::asio::socket_base::wait_read, + net::socket_base::wait_read, std::bind( &session::on_read, shared_from_this(), @@ -147,17 +147,17 @@ public: void testAsync() { - boost::asio::ip::tcp::endpoint ep( - boost::asio::ip::make_address("127.0.0.1"), 8080); + net::ip::tcp::endpoint ep( + net::ip::make_address("127.0.0.1"), 8080); server srv(ep, log); { - boost::asio::io_context ioc; + net::io_context ioc; set_timeout_service_options( ioc, std::chrono::seconds(1)); timeout_socket s(ioc); s.next_layer().connect(ep); char buf[32]; - s.async_read_some(boost::asio::buffer(buf), + s.async_read_some(net::buffer(buf), [&](error_code ec, std::size_t n) { log << "read_some: " << ec.message() << "\n"; diff --git a/test/beast/http/basic_parser.cpp b/test/beast/http/basic_parser.cpp index c51b81db..fa6685ab 100644 --- a/test/beast/http/basic_parser.cpp +++ b/test/beast/http/basic_parser.cpp @@ -152,11 +152,11 @@ public: template typename std::enable_if< - boost::asio::is_const_buffer_sequence::value>::type + net::is_const_buffer_sequence::value>::type parsegrind(ConstBufferSequence const& buffers, Test const& test, bool skip = false) { - auto const size = boost::asio::buffer_size(buffers); + auto const size = net::buffer_size(buffers); for(std::size_t i = 1; i < size - 1; ++i) { Parser p; @@ -174,7 +174,7 @@ public: n = p.put(cb, ec); if(! BEAST_EXPECTS(! ec, ec.message())) continue; - if(! BEAST_EXPECT(n == boost::asio::buffer_size(cb))) + if(! BEAST_EXPECT(n == net::buffer_size(cb))) continue; if(p.need_eof()) { @@ -213,13 +213,13 @@ public: void parsegrind(string_view msg, Test const& test, bool skip = false) { - parsegrind(boost::asio::const_buffer{ + parsegrind(net::const_buffer{ msg.data(), msg.size()}, test, skip); } template typename std::enable_if< - boost::asio::is_const_buffer_sequence::value>::type + net::is_const_buffer_sequence::value>::type parsegrind(ConstBufferSequence const& buffers) { parsegrind(buffers, [](Parser const&){}); @@ -241,7 +241,7 @@ public: Parser p; p.eager(true); error_code ec; - buffers_suffix cb{ + buffers_suffix cb{ boost::in_place_init, msg.data(), msg.size()}; auto n = p.put(buffers_prefix(i, cb), ec); if(ec == result) @@ -266,8 +266,8 @@ public: p.eager(true); error_code ec; p.put(buffers_cat( - boost::asio::const_buffer{msg.data(), i}, - boost::asio::const_buffer{ + net::const_buffer{msg.data(), i}, + net::const_buffer{ msg.data() + i, msg.size() - i}), ec); if(! ec) p.put_eof(ec); @@ -887,7 +887,7 @@ public: //-------------------------------------------------------------------------- static - boost::asio::const_buffer + net::const_buffer buf(string_view s) { return {s.data(), s.size()}; @@ -1080,7 +1080,7 @@ public: "GET / HTTP/1.1\r\n" "\r\n" "die!"; - p.put(boost::asio::buffer( + p.put(net::buffer( s.data(), s.size()), ec); if(! BEAST_EXPECTS(! ec, ec.message())) return; @@ -1117,7 +1117,7 @@ public: "HTTP/1.1 101 Switching Protocols\r\n" "Content-Length: 2147483648\r\n" "\r\n"; - p.put(boost::asio::buffer( + p.put(net::buffer( s.data(), s.size()), ec); if(! BEAST_EXPECTS(! ec, ec.message())) return; @@ -1140,7 +1140,7 @@ public: error_code ec; test_parser p; p.eager(true); - p.put(boost::asio::const_buffer{ + p.put(net::const_buffer{ s.data(), s.size()}, ec); }); }; @@ -1156,7 +1156,7 @@ public: error_code ec; test_parser p; p.eager(true); - p.put(boost::asio::const_buffer{ + p.put(net::const_buffer{ msg.data(), msg.size()}, ec); BEAST_EXPECTS(! ec, ec.message()); grind(msg); @@ -1173,7 +1173,7 @@ public: error_code ec; test_parser p; p.eager(true); - p.put(boost::asio::const_buffer{ + p.put(net::const_buffer{ msg.data(), msg.size()}, ec); BEAST_EXPECT(ec); grind(msg); @@ -1209,7 +1209,7 @@ public: error_code ec; test_parser p; - feed(boost::asio::buffer(buf, sizeof(buf)), p, ec); + feed(net::buffer(buf, sizeof(buf)), p, ec); BEAST_EXPECT(ec); } diff --git a/test/beast/http/chunk_encode.cpp b/test/beast/http/chunk_encode.cpp index 7e85029c..8d15c228 100644 --- a/test/beast/http/chunk_encode.cpp +++ b/test/beast/http/chunk_encode.cpp @@ -60,7 +60,7 @@ public: BEAST_EXPECT(buffers_to_string(t3) == match); } - using cb_t = boost::asio::const_buffer; + using cb_t = net::const_buffer; static cb_t diff --git a/test/beast/http/dynamic_body.cpp b/test/beast/http/dynamic_body.cpp index 0b18c908..e9de8384 100644 --- a/test/beast/http/dynamic_body.cpp +++ b/test/beast/http/dynamic_body.cpp @@ -25,7 +25,7 @@ namespace http { class dynamic_body_test : public beast::unit_test::suite { - boost::asio::io_context ioc_; + net::io_context ioc_; public: template diff --git a/test/beast/http/file_body.cpp b/test/beast/http/file_body.cpp index 032837f3..b4d7b311 100644 --- a/test/beast/http/file_body.cpp +++ b/test/beast/http/file_body.cpp @@ -33,8 +33,8 @@ public: void operator()(error_code&, ConstBufferSequence const& buffers) { - buffer.commit(boost::asio::buffer_copy( - buffer.prepare(boost::asio::buffer_size(buffers)), + buffer.commit(net::buffer_copy( + buffer.prepare(net::buffer_size(buffers)), buffers)); } }; @@ -59,7 +59,7 @@ public: temp.string().c_str(), file_mode::write, ec); BEAST_EXPECTS(! ec, ec.message()); - p.put(boost::asio::buffer(s.data(), s.size()), ec); + p.put(net::buffer(s.data(), s.size()), ec); BEAST_EXPECTS(! ec, ec.message()); } { diff --git a/test/beast/http/message_fuzz.hpp b/test/beast/http/message_fuzz.hpp index 56643735..4a60335b 100644 --- a/test/beast/http/message_fuzz.hpp +++ b/test/beast/http/message_fuzz.hpp @@ -504,11 +504,11 @@ public: ostream(db) << "Content-Length: " << len << "\r\n\r\n"; auto mb = db.prepare(len); - for(auto it = boost::asio::buffer_sequence_begin(mb); - it != boost::asio::buffer_sequence_end(mb); + for(auto it = net::buffer_sequence_begin(mb); + it != net::buffer_sequence_end(mb); ++it) { - boost::asio::mutable_buffer b = *it; + net::mutable_buffer b = *it; auto p = static_cast(b.data()); auto n = b.size(); while(n--) @@ -528,11 +528,11 @@ public: ostream(db) << to_hex(n) << "\r\n"; auto mb = db.prepare(n); - for(auto it = boost::asio::buffer_sequence_begin(mb); - it != boost::asio::buffer_sequence_end(mb); + for(auto it = net::buffer_sequence_begin(mb); + it != net::buffer_sequence_end(mb); ++it) { - boost::asio::mutable_buffer b = *it; + net::mutable_buffer b = *it; auto p = static_cast(b.data()); auto m = b.size(); while(m--) diff --git a/test/beast/http/parser.cpp b/test/beast/http/parser.cpp index 174a83ff..fc3aefe1 100644 --- a/test/beast/http/parser.cpp +++ b/test/beast/http/parser.cpp @@ -37,7 +37,7 @@ public: parser; static - boost::asio::const_buffer + net::const_buffer buf(string_view s) { return {s.data(), s.size()}; @@ -51,7 +51,7 @@ public: basic_parser& p, error_code& ec) { - using boost::asio::buffer_size; + using net::buffer_size; buffers_suffix cb{buffers}; for(;;) { @@ -75,7 +75,7 @@ public: void doMatrix(string_view s0, F const& f) { - using boost::asio::buffer; + using net::buffer; // parse a single buffer { auto s = s0; diff --git a/test/beast/http/read.cpp b/test/beast/http/read.cpp index b639c5fa..2164d434 100644 --- a/test/beast/http/read.cpp +++ b/test/beast/http/read.cpp @@ -38,8 +38,8 @@ public: void failMatrix(char const* s, yield_context do_yield) { - using boost::asio::buffer; - using boost::asio::buffer_copy; + using net::buffer; + using net::buffer_copy; static std::size_t constexpr limit = 100; std::size_t n; auto const len = strlen(s); @@ -373,7 +373,7 @@ public: { // Make sure handlers are not destroyed // after calling io_context::stop - boost::asio::io_context ioc; + net::io_context ioc; test::stream ts{ioc, "GET / HTTP/1.1\r\n\r\n"}; BEAST_EXPECT(handler::count() == 0); @@ -392,7 +392,7 @@ public: // Make sure uninvoked handlers are // destroyed when calling ~io_context { - boost::asio::io_context ioc; + net::io_context ioc; test::stream ts{ioc, "GET / HTTP/1.1\r\n\r\n"}; BEAST_EXPECT(handler::count() == 0); @@ -431,7 +431,7 @@ public: void readgrind(string_view s, Pred&& pred) { - using boost::asio::buffer; + using net::buffer; for(std::size_t n = 1; n < s.size() - 1; ++n) { Parser p; @@ -493,40 +493,40 @@ public: void testAsioHandlerInvoke() { - using strand = boost::asio::strand< - boost::asio::io_context::executor_type>; + using strand = net::strand< + net::io_context::executor_type>; // make sure things compile, also can set a // breakpoint in asio_handler_invoke to make sure // it is instantiated. { - boost::asio::io_context ioc; + net::io_context ioc; strand s{ioc.get_executor()}; test::stream ts{ioc}; flat_buffer b; request_parser p; async_read_some(ts, b, p, - boost::asio::bind_executor( + net::bind_executor( s, copyable_handler{})); } { - boost::asio::io_context ioc; + net::io_context ioc; strand s{ioc.get_executor()}; test::stream ts{ioc}; flat_buffer b; request_parser p; async_read(ts, b, p, - boost::asio::bind_executor( + net::bind_executor( s, copyable_handler{})); } { - boost::asio::io_context ioc; + net::io_context ioc; strand s{ioc.get_executor()}; test::stream ts{ioc}; flat_buffer b; request m; async_read(ts, b, m, - boost::asio::bind_executor( + net::bind_executor( s, copyable_handler{})); } } diff --git a/test/beast/http/serializer.cpp b/test/beast/http/serializer.cpp index dad3fedb..839a272f 100644 --- a/test/beast/http/serializer.cpp +++ b/test/beast/http/serializer.cpp @@ -27,7 +27,7 @@ public: struct writer { using const_buffers_type = - boost::asio::const_buffer; + net::const_buffer; template writer(header const&, value_type const&); @@ -47,7 +47,7 @@ public: struct writer { using const_buffers_type = - boost::asio::const_buffer; + net::const_buffer; template writer(header&, value_type&); @@ -91,7 +91,7 @@ public: operator()(error_code&, ConstBufferSequence const& buffers) { - size = boost::asio::buffer_size(buffers); + size = net::buffer_size(buffers); } }; diff --git a/test/beast/http/span_body.cpp b/test/beast/http/span_body.cpp index 7f6fee7b..8f4a14f2 100644 --- a/test/beast/http/span_body.cpp +++ b/test/beast/http/span_body.cpp @@ -42,7 +42,7 @@ struct span_body_test BEAST_EXPECTS(! ec, ec.message()); if(! BEAST_EXPECT(buf != boost::none)) return; - BEAST_EXPECT(boost::asio::buffer_size(buf->first) == 3); + BEAST_EXPECT(net::buffer_size(buf->first) == 3); BEAST_EXPECT(! buf->second); } { @@ -54,13 +54,13 @@ struct span_body_test error_code ec; w.init(boost::none, ec); BEAST_EXPECTS(! ec, ec.message()); - w.put(boost::asio::const_buffer{ + w.put(net::const_buffer{ "123", 3}, ec); BEAST_EXPECTS(! ec, ec.message()); BEAST_EXPECT(buf[0] == '1'); BEAST_EXPECT(buf[1] == '2'); BEAST_EXPECT(buf[2] == '3'); - w.put(boost::asio::const_buffer{ + w.put(net::const_buffer{ "456", 3}, ec); BEAST_EXPECTS(ec == error::buffer_overflow, ec.message()); } diff --git a/test/beast/http/test_parser.hpp b/test/beast/http/test_parser.hpp index 0cee9e75..def84b21 100644 --- a/test/beast/http/test_parser.hpp +++ b/test/beast/http/test_parser.hpp @@ -27,7 +27,7 @@ class test_parser public: using mutable_buffers_type = - boost::asio::mutable_buffer; + net::mutable_buffer; int status = 0; int version = 0; diff --git a/test/beast/http/write.cpp b/test/beast/http/write.cpp index 2ec038e0..cbfe931b 100644 --- a/test/beast/http/write.cpp +++ b/test/beast/http/write.cpp @@ -47,7 +47,7 @@ public: public: using const_buffers_type = - boost::asio::const_buffer; + net::const_buffer; template writer( @@ -92,7 +92,7 @@ public: public: using const_buffers_type = - boost::asio::const_buffer; + net::const_buffer; template writer( @@ -124,7 +124,7 @@ public: std::false_type, // isSplit std::false_type) // isFinalEmpty { - using boost::asio::buffer; + using net::buffer; if(body_.s.empty()) return boost::none; return {{buffer(body_.s.data(), body_.s.size()), false}}; @@ -135,7 +135,7 @@ public: std::false_type, // isSplit std::true_type) // isFinalEmpty { - using boost::asio::buffer; + using net::buffer; if(body_.s.empty()) return boost::none; switch(step_) @@ -154,7 +154,7 @@ public: std::true_type, // isSplit std::false_type) // isFinalEmpty { - using boost::asio::buffer; + using net::buffer; auto const n = (body_.s.size() + 1) / 2; switch(step_) { @@ -175,7 +175,7 @@ public: std::true_type, // isSplit std::true_type) // isFinalEmpty { - using boost::asio::buffer; + using net::buffer; auto const n = (body_.s.size() + 1) / 2; switch(step_) { @@ -229,7 +229,7 @@ public: public: using const_buffers_type = - boost::asio::const_buffer; + net::const_buffer; template explicit @@ -636,7 +636,7 @@ public: { // Make sure handlers are not destroyed // after calling io_context::stop - boost::asio::io_context ioc; + net::io_context ioc; test::stream ts{ioc}; BEAST_EXPECT(handler::count() == 0); request m; @@ -658,7 +658,7 @@ public: // Make sure uninvoked handlers are // destroyed when calling ~io_context { - boost::asio::io_context ioc; + net::io_context ioc; test::stream ts{ioc}, tr{ioc}; ts.connect(tr); BEAST_EXPECT(handler::count() == 0); @@ -718,7 +718,7 @@ public: template void - testWriteStream(boost::asio::yield_context yield) + testWriteStream(net::yield_context yield) { test::stream ts{ioc_}, tr{ioc_}; ts.connect(tr); @@ -832,7 +832,7 @@ public: void testIssue655() { - boost::asio::io_context ioc; + net::io_context ioc; test::stream ts{ioc}, tr{ioc}; ts.connect(tr); response res; @@ -857,42 +857,42 @@ public: void testAsioHandlerInvoke() { - using strand = boost::asio::strand< - boost::asio::io_context::executor_type>; + using strand = net::strand< + net::io_context::executor_type>; // make sure things compile, also can set a // breakpoint in asio_handler_invoke to make sure // it is instantiated. { - boost::asio::io_context ioc; + net::io_context ioc; strand s{ioc.get_executor()}; test::stream ts{ioc}; flat_buffer b; request m; request_serializer sr{m}; async_write_some(ts, sr, - boost::asio::bind_executor( + net::bind_executor( s, copyable_handler{})); } { - boost::asio::io_context ioc; + net::io_context ioc; strand s{ioc.get_executor()}; test::stream ts{ioc}; flat_buffer b; request m; request_serializer sr{m}; async_write(ts, sr, - boost::asio::bind_executor( + net::bind_executor( s, copyable_handler{})); } { - boost::asio::io_context ioc; + net::io_context ioc; strand s{ioc.get_executor()}; test::stream ts{ioc}; flat_buffer b; request m; async_write(ts, m, - boost::asio::bind_executor( + net::bind_executor( s, copyable_handler{})); } } @@ -904,7 +904,7 @@ public: struct writer { using const_buffers_type = - boost::asio::const_buffer; + net::const_buffer; template writer( @@ -935,7 +935,7 @@ public: struct writer { using const_buffers_type = - boost::asio::const_buffer; + net::const_buffer; template writer( diff --git a/test/beast/websocket/accept.cpp b/test/beast/websocket/accept.cpp index a66f4525..e900989e 100644 --- a/test/beast/websocket/accept.cpp +++ b/test/beast/websocket/accept.cpp @@ -165,7 +165,7 @@ public: auto tr = connect(ws.next_layer()); try { - w.accept(ws, boost::asio::buffer( + w.accept(ws, net::buffer( "GET / HTTP/1.1\r\n" "Host: localhost\r\n" "Upgrade: websocket\r\n" @@ -210,7 +210,7 @@ public: try { bool called = false; - w.accept_ex(ws, boost::asio::buffer( + w.accept_ex(ws, net::buffer( "GET / HTTP/1.1\r\n" "Host: localhost\r\n" "Upgrade: websocket\r\n" @@ -411,7 +411,7 @@ public: if( e.code() != websocket::error::no_sec_key && e.code() != - boost::asio::error::eof) + net::error::eof) throw; } }); @@ -476,7 +476,7 @@ public: try { ws.accept( - boost::asio::buffer(s.data(), n)); + net::buffer(s.data(), n)); BEAST_EXPECTS(! ev, ev.message()); } catch(system_error const& se) @@ -616,7 +616,7 @@ public: void testMoveOnly() { - boost::asio::io_context ioc; + net::io_context ioc; stream ws{ioc}; ws.async_accept(move_only_handler{}); } @@ -636,12 +636,12 @@ public: // make sure things compile, also can set a // breakpoint in asio_handler_invoke to make sure // it is instantiated. - boost::asio::io_context ioc; - boost::asio::strand< - boost::asio::io_context::executor_type> s( + net::io_context ioc; + net::strand< + net::io_context::executor_type> s( ioc.get_executor()); stream ws{ioc}; - ws.async_accept(boost::asio::bind_executor( + ws.async_accept(net::bind_executor( s, copyable_handler{})); } diff --git a/test/beast/websocket/close.cpp b/test/beast/websocket/close.cpp index 5b25321b..554e7295 100644 --- a/test/beast/websocket/close.cpp +++ b/test/beast/websocket/close.cpp @@ -65,7 +65,7 @@ public: catch(system_error const& se) { BEAST_EXPECTS( - se.code() == boost::asio::error::operation_aborted, + se.code() == net::error::operation_aborted, se.code().message()); } } @@ -171,13 +171,13 @@ public: void testSuspend() { - using boost::asio::buffer; + using net::buffer; // suspend on ping doFailLoop([&](test::fail_count& fc) { echo_server es{log}; - boost::asio::io_context ioc; + net::io_context ioc; stream ws{ioc, fc}; ws.next_layer().connect(es.stream()); ws.handshake("localhost", "/"); @@ -209,7 +209,7 @@ public: doFailLoop([&](test::fail_count& fc) { echo_server es{log}; - boost::asio::io_context ioc; + net::io_context ioc; stream ws{ioc, fc}; ws.next_layer().connect(es.stream()); ws.handshake("localhost", "/"); @@ -242,7 +242,7 @@ public: doFailLoop([&](test::fail_count& fc) { echo_server es{log}; - boost::asio::io_context ioc; + net::io_context ioc; stream ws{ioc, fc}; ws.next_layer().connect(es.stream()); ws.handshake("localhost", "/"); @@ -283,7 +283,7 @@ public: doFailLoop([&](test::fail_count& fc) { echo_server es{log}; - boost::asio::io_context ioc; + net::io_context ioc; stream ws{ioc, fc}; ws.next_layer().connect(es.stream()); ws.handshake("localhost", "/"); @@ -310,7 +310,7 @@ public: ws.async_close({}, [&](error_code ec) { - if(ec != boost::asio::error::operation_aborted) + if(ec != net::error::operation_aborted) BOOST_THROW_EXCEPTION( system_error{ec}); BEAST_EXPECT(++count == 2); @@ -324,7 +324,7 @@ public: doFailLoop([&](test::fail_count& fc) { echo_server es{log}; - boost::asio::io_context ioc; + net::io_context ioc; stream ws{ioc, fc}; ws.next_layer().connect(es.stream()); ws.handshake("localhost", "/"); @@ -351,7 +351,7 @@ public: ws.async_close({}, [&](error_code ec) { - if(ec != boost::asio::error::operation_aborted) + if(ec != net::error::operation_aborted) BOOST_THROW_EXCEPTION( system_error{ec}); BEAST_EXPECT(++count == 2); @@ -365,7 +365,7 @@ public: doFailLoop([&](test::fail_count& fc) { echo_server es{log}; - boost::asio::io_context ioc; + net::io_context ioc; stream ws{ioc, fc}; ws.next_layer().connect(es.stream()); ws.handshake("localhost", "/"); @@ -387,7 +387,7 @@ public: ws.async_read(b, [&](error_code ec, std::size_t) { - if(ec != boost::asio::error::operation_aborted) + if(ec != net::error::operation_aborted) BOOST_THROW_EXCEPTION( system_error{ec}); BEAST_EXPECT(++count == 3); @@ -409,7 +409,7 @@ public: doFailLoop([&](test::fail_count& fc) { echo_server es{log}; - boost::asio::io_context ioc; + net::io_context ioc; stream ws{ioc, fc}; ws.next_layer().connect(es.stream()); ws.handshake("localhost", "/"); @@ -431,7 +431,7 @@ public: ws.async_read(b, [&](error_code ec, std::size_t) { - if(ec != boost::asio::error::operation_aborted) + if(ec != net::error::operation_aborted) BOOST_THROW_EXCEPTION( system_error{ec}); BEAST_EXPECT(++count == 3); @@ -456,7 +456,7 @@ public: doFailLoop([&](test::fail_count& fc) { echo_server es{log}; - boost::asio::io_context ioc; + net::io_context ioc; stream ws{ioc, fc}; ws.next_layer().connect(es.stream()); ws.handshake("localhost", "/"); @@ -474,7 +474,7 @@ public: ws.async_read(b, [&](error_code ec, std::size_t) { - if(ec != boost::asio::error::operation_aborted) + if(ec != net::error::operation_aborted) BOOST_THROW_EXCEPTION( system_error{ec}); ++count; @@ -482,7 +482,7 @@ public: ws.async_write(buffer(s), [&](error_code ec, std::size_t) { - if(ec != boost::asio::error::operation_aborted) + if(ec != net::error::operation_aborted) BOOST_THROW_EXCEPTION( system_error{ec}); ++count; @@ -490,7 +490,7 @@ public: ws.async_ping({}, [&](error_code ec) { - if(ec != boost::asio::error::operation_aborted) + if(ec != net::error::operation_aborted) BOOST_THROW_EXCEPTION( system_error{ec}); ++count; @@ -504,7 +504,7 @@ public: doFailLoop([&](test::fail_count& fc) { echo_server es{log}; - boost::asio::io_context ioc; + net::io_context ioc; stream ws{ioc, fc}; ws.next_layer().connect(es.stream()); ws.handshake("localhost", "/"); @@ -514,7 +514,7 @@ public: ws.async_read(b, [&](error_code ec, std::size_t) { - if(ec && ec != boost::asio::error::operation_aborted) + if(ec && ec != net::error::operation_aborted) { BEAST_EXPECTS(ec, ec.message()); BOOST_THROW_EXCEPTION( @@ -525,7 +525,7 @@ public: ++count; if(count == 4) BEAST_EXPECT( - ec == boost::asio::error::operation_aborted); + ec == net::error::operation_aborted); }); ws.async_write(buffer(s), [&](error_code ec, std::size_t n) @@ -539,7 +539,7 @@ public: ws.async_ping({}, [&](error_code ec) { - if(ec != boost::asio::error::operation_aborted) + if(ec != net::error::operation_aborted) { BEAST_EXPECTS(ec, ec.message()); BOOST_THROW_EXCEPTION( @@ -565,7 +565,7 @@ public: doFailLoop([&](test::fail_count& fc) { echo_server es{log}; - boost::asio::io_context ioc; + net::io_context ioc; stream ws{ioc, fc}; ws.next_layer().connect(es.stream()); ws.handshake("localhost", "/"); @@ -583,7 +583,7 @@ public: ws.async_read(b, [&](error_code ec, std::size_t) { - if(ec != boost::asio::error::operation_aborted) + if(ec != net::error::operation_aborted) BOOST_THROW_EXCEPTION( system_error{ec}); ++count; @@ -591,7 +591,7 @@ public: ws.async_write(buffer(s), [&](error_code ec, std::size_t) { - if(ec != boost::asio::error::operation_aborted) + if(ec != net::error::operation_aborted) BOOST_THROW_EXCEPTION( system_error{ec}); ++count; @@ -621,14 +621,14 @@ public: stream ws{ioc_}; stream::close_op op{ handler{}, ws, {}}; - using boost::asio::asio_handler_is_continuation; + using net::asio_handler_is_continuation; asio_handler_is_continuation(&op); } void testMoveOnly() { - boost::asio::io_context ioc; + net::io_context ioc; stream ws{ioc}; ws.async_close({}, move_only_handler{}); } @@ -648,12 +648,12 @@ public: // make sure things compile, also can set a // breakpoint in asio_handler_invoke to make sure // it is instantiated. - boost::asio::io_context ioc; - boost::asio::strand< - boost::asio::io_context::executor_type> s( + net::io_context ioc; + net::strand< + net::io_context::executor_type> s( ioc.get_executor()); stream ws{ioc}; - ws.async_close({}, boost::asio::bind_executor( + ws.async_close({}, net::bind_executor( s, copyable_handler{})); } diff --git a/test/beast/websocket/doc_snippets.cpp b/test/beast/websocket/doc_snippets.cpp index 751d099d..4539350a 100644 --- a/test/beast/websocket/doc_snippets.cpp +++ b/test/beast/websocket/doc_snippets.cpp @@ -27,53 +27,53 @@ namespace doc_ws_snippets { void fxx() { -boost::asio::io_service ios; -boost::asio::io_service::work work{ios}; +net::io_service ios; +net::io_service::work work{ios}; std::thread t{[&](){ ios.run(); }}; error_code ec; -boost::asio::ip::tcp::socket sock{ios}; +net::ip::tcp::socket sock{ios}; { //[ws_snippet_2 - stream ws{ios}; + stream ws{ios}; //] } { //[ws_snippet_3 - stream ws{std::move(sock)}; + stream ws{std::move(sock)}; //] } { //[ws_snippet_4 - stream ws{sock}; + stream ws{sock}; //] //[ws_snippet_5 - ws.next_layer().shutdown(boost::asio::ip::tcp::socket::shutdown_send); + ws.next_layer().shutdown(net::ip::tcp::socket::shutdown_send); //] } { //[ws_snippet_6 std::string const host = "mywebapp.com"; - boost::asio::ip::tcp::resolver r{ios}; - stream ws{ios}; - boost::asio::connect(ws.next_layer(), r.resolve({host, "ws"})); + net::ip::tcp::resolver r{ios}; + stream ws{ios}; + net::connect(ws.next_layer(), r.resolve({host, "ws"})); //] } { //[ws_snippet_7 - boost::asio::ip::tcp::acceptor acceptor{ios}; - stream ws{acceptor.get_io_service()}; + net::ip::tcp::acceptor acceptor{ios}; + stream ws{acceptor.get_io_service()}; acceptor.accept(ws.next_layer()); //] } { - stream ws{ios}; + stream ws{ios}; //[ws_snippet_8 ws.handshake("localhost", "/"); //] @@ -119,7 +119,7 @@ boost::asio::ip::tcp::socket sock{ios}; if(websocket::is_upgrade(req)) { // Construct the stream, transferring ownership of the socket - stream ws{std::move(sock)}; + stream ws{std::move(sock)}; // Accept the request from our message. Clients SHOULD NOT // begin sending WebSocket frames until the server has @@ -137,19 +137,19 @@ boost::asio::ip::tcp::socket sock{ios}; } { - stream ws{ios}; + stream ws{ios}; //[ws_snippet_14 // Read into our buffer until we reach the end of the HTTP request. // No parsing takes place here, we are just accumulating data. - boost::asio::streambuf buffer; - boost::asio::read_until(sock, buffer, "\r\n\r\n"); + net::streambuf buffer; + net::read_until(sock, buffer, "\r\n\r\n"); // Now accept the connection, using the buffered data. ws.accept(buffer.data()); //] } { - stream ws{ios}; + stream ws{ios}; //[ws_snippet_15 multi_buffer buffer; ws.read(buffer); @@ -161,7 +161,7 @@ boost::asio::ip::tcp::socket sock{ios}; } { - stream ws{ios}; + stream ws{ios}; //[ws_snippet_16 multi_buffer buffer; for(;;) @@ -171,7 +171,7 @@ boost::asio::ip::tcp::socket sock{ios}; consuming_buffers cb{buffer.data()}; for(;;) { - using boost::asio::buffer_size; + using net::buffer_size; if(buffer_size(cb) > 512) { ws.write_some(false, buffer_prefix(512, cb)); @@ -187,7 +187,7 @@ boost::asio::ip::tcp::socket sock{ios}; } { - stream ws{ios}; + stream ws{ios}; //[ws_snippet_17 auto cb = [](frame_type kind, string_view payload) @@ -222,12 +222,12 @@ boost::asio::ip::tcp::socket sock{ios}; // workaround for https://github.com/chriskohlhoff/asio/issues/112 #ifdef BOOST_MSVC //[ws_snippet_21 -void echo(stream& ws, - multi_buffer& buffer, boost::asio::yield_context yield) +void echo(stream& ws, + multi_buffer& buffer, net::yield_context yield) { ws.async_read(buffer, yield); std::future fut = - ws.async_write(buffer.data(), boost::asio::use_future); + ws.async_write(buffer.data(), net::use_future); } //] #endif @@ -247,30 +247,30 @@ namespace doc_wss_snippets { void fxx() { -boost::asio::io_service ios; -boost::asio::io_service::work work{ios}; +net::io_service ios; +net::io_service::work work{ios}; std::thread t{[&](){ ios.run(); }}; error_code ec; -boost::asio::ip::tcp::socket sock{ios}; +net::ip::tcp::socket sock{ios}; { //[wss_snippet_2 - boost::asio::ssl::context ctx{boost::asio::ssl::context::sslv23}; - stream> wss{ios, ctx}; + net::ssl::context ctx{net::ssl::context::sslv23}; + stream> wss{ios, ctx}; //] } { //[wss_snippet_3 - boost::asio::ip::tcp::endpoint ep; - boost::asio::ssl::context ctx{boost::asio::ssl::context::sslv23}; - stream> ws{ios, ctx}; + net::ip::tcp::endpoint ep; + net::ssl::context ctx{net::ssl::context::sslv23}; + stream> ws{ios, ctx}; // connect the underlying TCP/IP socket ws.next_layer().next_layer().connect(ep); // perform SSL handshake - ws.next_layer().handshake(boost::asio::ssl::stream_base::client); + ws.next_layer().handshake(net::ssl::stream_base::client); // perform WebSocket handshake ws.handshake("localhost", "/"); diff --git a/test/beast/websocket/handshake.cpp b/test/beast/websocket/handshake.cpp index 69397922..94653050 100644 --- a/test/beast/websocket/handshake.cpp +++ b/test/beast/websocket/handshake.cpp @@ -490,7 +490,7 @@ public: void testMoveOnly() { - boost::asio::io_context ioc; + net::io_context ioc; stream ws{ioc}; ws.async_handshake("", "", move_only_handler{}); } @@ -510,13 +510,13 @@ public: // make sure things compile, also can set a // breakpoint in asio_handler_invoke to make sure // it is instantiated. - boost::asio::io_context ioc; - boost::asio::strand< - boost::asio::io_context::executor_type> s( + net::io_context ioc; + net::strand< + net::io_context::executor_type> s( ioc.get_executor()); stream ws{ioc}; ws.async_handshake("localhost", "/", - boost::asio::bind_executor( + net::bind_executor( s, copyable_handler{})); } diff --git a/test/beast/websocket/ping.cpp b/test/beast/websocket/ping.cpp index 49be4808..aa539cbb 100644 --- a/test/beast/websocket/ping.cpp +++ b/test/beast/websocket/ping.cpp @@ -57,7 +57,7 @@ public: catch(system_error const& se) { BEAST_EXPECTS( - se.code() == boost::asio::error::operation_aborted, + se.code() == net::error::operation_aborted, se.code().message()); } } @@ -77,7 +77,7 @@ public: catch(system_error const& se) { BEAST_EXPECTS( - se.code() == boost::asio::error::operation_aborted, + se.code() == net::error::operation_aborted, se.code().message()); } } @@ -101,7 +101,7 @@ public: doFailLoop([&](test::fail_count& fc) { echo_server es{log}; - boost::asio::io_context ioc; + net::io_context ioc; stream ws{ioc, fc}; ws.next_layer().connect(es.stream()); ws.handshake("localhost", "/"); @@ -134,7 +134,7 @@ public: doFailLoop([&](test::fail_count& fc) { echo_server es{log}; - boost::asio::io_context ioc; + net::io_context ioc; stream ws{ioc, fc}; ws.next_layer().connect(es.stream()); ws.handshake("localhost", "/"); @@ -153,7 +153,7 @@ public: [&](error_code ec) { ++count; - if(ec != boost::asio::error::operation_aborted) + if(ec != net::error::operation_aborted) BOOST_THROW_EXCEPTION( system_error{ec}); }); @@ -166,7 +166,7 @@ public: doFailLoop([&](test::fail_count& fc) { echo_server es{log}; - boost::asio::io_context ioc; + net::io_context ioc; stream ws{ioc, fc}; ws.next_layer().connect(es.stream()); ws.handshake("localhost", "/"); @@ -207,7 +207,7 @@ public: doFailLoop([&](test::fail_count& fc) { echo_server es{log}; - boost::asio::io_context ioc; + net::io_context ioc; stream ws{ioc, fc}; ws.next_layer().connect(es.stream()); ws.handshake("localhost", "/"); @@ -236,7 +236,7 @@ public: [&](error_code ec) { ++count; - if(ec != boost::asio::error::operation_aborted) + if(ec != net::error::operation_aborted) BOOST_THROW_EXCEPTION( system_error{ec}); }); @@ -249,7 +249,7 @@ public: doFailLoop([&](test::fail_count& fc) { echo_server es{log}; - boost::asio::io_context ioc; + net::io_context ioc; stream ws{ioc, fc}; ws.next_layer().connect(es.stream()); ws.handshake("localhost", "/"); @@ -277,7 +277,7 @@ public: [&](error_code ec) { ++count; - if(ec != boost::asio::error::operation_aborted) + if(ec != net::error::operation_aborted) BOOST_THROW_EXCEPTION( system_error{ec}); }); @@ -290,7 +290,7 @@ public: doFailLoop([&](test::fail_count& fc) { echo_server es{log, kind::async}; - boost::asio::io_context ioc; + net::io_context ioc; stream ws{ioc, fc}; ws.next_layer().connect(es.stream()); ws.handshake("localhost", "/"); @@ -317,7 +317,7 @@ public: [&](error_code ec) { ++count; - if(ec != boost::asio::error::operation_aborted) + if(ec != net::error::operation_aborted) BOOST_THROW_EXCEPTION( system_error{ec}); }); @@ -331,7 +331,7 @@ public: { echo_server es{log}; error_code ec; - boost::asio::io_context ioc; + net::io_context ioc; stream ws{ioc, fc}; ws.next_layer().connect(es.stream()); ws.handshake("localhost", "/"); @@ -350,7 +350,7 @@ public: [&](error_code ec) { ++count; - if(ec != boost::asio::error::operation_aborted) + if(ec != net::error::operation_aborted) BOOST_THROW_EXCEPTION( system_error{ec}); }); @@ -368,7 +368,7 @@ public: { echo_server es{log, kind::async}; - boost::asio::io_context ioc; + net::io_context ioc; stream ws{ioc}; ws.next_layer().connect(es.stream()); ws.handshake("localhost", "/"); @@ -397,7 +397,7 @@ public: { // Pings after a close are aborted ++count; - BEAST_EXPECTS(ec == boost::asio:: + BEAST_EXPECTS(ec == net:: error::operation_aborted, ec.message()); // Subsequent calls to close are aborted @@ -405,7 +405,7 @@ public: [&](error_code ec) { ++count; - BEAST_EXPECTS(ec == boost::asio:: + BEAST_EXPECTS(ec == net:: error::operation_aborted, ec.message()); }); @@ -434,14 +434,14 @@ public: stream ws{ioc_}; stream::ping_op op{ handler{}, ws, detail::opcode::ping, {}}; - using boost::asio::asio_handler_is_continuation; + using net::asio_handler_is_continuation; asio_handler_is_continuation(&op); } void testMoveOnly() { - boost::asio::io_context ioc; + net::io_context ioc; stream ws{ioc}; ws.async_ping({}, move_only_handler{}); } @@ -461,12 +461,12 @@ public: // make sure things compile, also can set a // breakpoint in asio_handler_invoke to make sure // it is instantiated. - boost::asio::io_context ioc; - boost::asio::strand< - boost::asio::io_context::executor_type> s( + net::io_context ioc; + net::strand< + net::io_context::executor_type> s( ioc.get_executor()); stream ws{ioc}; - ws.async_ping({}, boost::asio::bind_executor( + ws.async_ping({}, net::bind_executor( s, copyable_handler{})); } diff --git a/test/beast/websocket/read1.cpp b/test/beast/websocket/read1.cpp index 1ea35b5b..9684ef40 100644 --- a/test/beast/websocket/read1.cpp +++ b/test/beast/websocket/read1.cpp @@ -75,7 +75,7 @@ public: void doTestRead(Wrap const& w) { - using boost::asio::buffer; + using net::buffer; permessage_deflate pmd; pmd.client_enable = false; @@ -97,7 +97,7 @@ public: catch(system_error const& se) { BEAST_EXPECTS( - se.code() == boost::asio::error::operation_aborted, + se.code() == net::error::operation_aborted, se.code().message()); } } @@ -248,7 +248,7 @@ public: doFailLoop([&](test::fail_count& fc) { echo_server es{log, kind::async}; - boost::asio::io_context ioc; + net::io_context ioc; stream ws{ioc, fc}; ws.next_layer().connect(es.stream()); ws.handshake("localhost", "/"); @@ -275,7 +275,7 @@ public: w.close(ws, {}); multi_buffer b; doFailTest(w, ws, - boost::asio::error::operation_aborted); + net::error::operation_aborted); }); // buffer overflow @@ -437,7 +437,7 @@ public: void doTestReadDeflate(Wrap const& w) { - using boost::asio::buffer; + using net::buffer; permessage_deflate pmd; pmd.client_enable = true; @@ -504,7 +504,7 @@ public: permessage_deflate const& pmd, Wrap const& w) { - using boost::asio::buffer; + using net::buffer; // message doTest(pmd, [&](ws_type& ws) @@ -613,7 +613,7 @@ public: void testRead() { - using boost::asio::buffer; + using net::buffer; doTestRead(SyncClient{}); doTestRead(SyncClient{}); diff --git a/test/beast/websocket/read2.cpp b/test/beast/websocket/read2.cpp index efafcfd7..24c2dedf 100644 --- a/test/beast/websocket/read2.cpp +++ b/test/beast/websocket/read2.cpp @@ -26,13 +26,13 @@ public: void testSuspend() { - using boost::asio::buffer; + using net::buffer; #if 1 // suspend on read block doFailLoop([&](test::fail_count& fc) { echo_server es{log}; - boost::asio::io_context ioc; + net::io_context ioc; stream ws{ioc, fc}; ws.next_layer().connect(es.stream()); ws.handshake("localhost", "/"); @@ -51,7 +51,7 @@ public: ws.async_read(b, [&](error_code ec, std::size_t) { - if(ec != boost::asio::error::operation_aborted) + if(ec != net::error::operation_aborted) BOOST_THROW_EXCEPTION( system_error{ec}); BEAST_EXPECT(++count == 2); @@ -66,7 +66,7 @@ public: { //log << "fc.count()==" << fc.count() << std::endl; echo_server es{log}; - boost::asio::io_context ioc; + net::io_context ioc; stream ws{ioc, fc}; ws.next_layer().connect(es.stream()); ws.handshake("localhost", "/"); @@ -75,7 +75,7 @@ public: ws.async_read(b, [&](error_code ec, std::size_t) { - if(ec != boost::asio::error::operation_aborted) + if(ec != net::error::operation_aborted) BOOST_THROW_EXCEPTION( system_error{ec}); BEAST_EXPECT(++count == 2); @@ -98,7 +98,7 @@ public: doFailLoop([&](test::fail_count& fc) { echo_server es{log}; - boost::asio::io_context ioc; + net::io_context ioc; stream ws{ioc, fc}; ws.next_layer().connect(es.stream()); ws.handshake("localhost", "/"); @@ -136,7 +136,7 @@ public: doFailLoop([&](test::fail_count& fc) { echo_server es{log}; - boost::asio::io_context ioc; + net::io_context ioc; stream ws{ioc, fc}; ws.next_layer().connect(es.stream()); ws.handshake("localhost", "/"); @@ -160,7 +160,7 @@ public: ws.async_read(b, [&](error_code ec, std::size_t) { - if(ec != boost::asio::error::operation_aborted) + if(ec != net::error::operation_aborted) BOOST_THROW_EXCEPTION( system_error{ec}); BEAST_EXPECT(++count == 3); @@ -184,7 +184,7 @@ public: doFailLoop([&](test::fail_count& fc) { echo_server es{log}; - boost::asio::io_context ioc; + net::io_context ioc; stream ws{ioc, fc}; ws.next_layer().connect(es.stream()); ws.handshake("localhost", "/"); @@ -199,7 +199,7 @@ public: ws.async_read(b, [&](error_code ec, std::size_t) { - if(ec != boost::asio::error::operation_aborted) + if(ec != net::error::operation_aborted) BOOST_THROW_EXCEPTION( system_error{ec}); BEAST_EXPECT(++count == 2); @@ -227,7 +227,7 @@ public: [&](string_view s) { echo_server es{log}; - boost::asio::io_context ioc; + net::io_context ioc; stream ws{ioc}; ws.next_layer().connect(es.stream()); ws.handshake("localhost", "/"); @@ -241,7 +241,7 @@ public: // chopped frame header { echo_server es{log}; - boost::asio::io_context ioc; + net::io_context ioc; stream ws{ioc}; ws.next_layer().connect(es.stream()); ws.handshake("localhost", "/"); @@ -259,7 +259,7 @@ public: }); ioc.run_one(); es.stream().write_some( - boost::asio::buffer("\x01" + s)); + net::buffer("\x01" + s)); ioc.run(); BEAST_EXPECT(count == 1); } @@ -297,7 +297,7 @@ public: // unmasked frame from client { echo_server es{log, kind::async_client}; - boost::asio::io_context ioc; + net::io_context ioc; stream ws{ioc}; ws.next_layer().connect(es.stream()); es.async_handshake(); @@ -316,7 +316,7 @@ public: // chopped control frame payload { echo_server es{log}; - boost::asio::io_context ioc; + net::io_context ioc; stream ws{ioc}; ws.next_layer().connect(es.stream()); ws.handshake("localhost", "/"); @@ -333,7 +333,7 @@ public: }); ioc.run_one(); es.stream().write_some( - boost::asio::buffer( + net::buffer( "*" "\x81\x02**")); ioc.run(); BEAST_EXPECT(count == 1); @@ -356,11 +356,11 @@ public: char buf[32]; stream ws{ioc_}; stream::read_some_op< - boost::asio::mutable_buffer, + net::mutable_buffer, handler> op{handler{}, ws, - boost::asio::mutable_buffer{ + net::mutable_buffer{ buf, sizeof(buf)}}; - using boost::asio::asio_handler_is_continuation; + using net::asio_handler_is_continuation; asio_handler_is_continuation(&op); pass(); } @@ -375,7 +375,7 @@ public: stream::read_op< multi_buffer, handler> op{ handler{}, ws, b, 32, true}; - using boost::asio::asio_handler_is_continuation; + using net::asio_handler_is_continuation; asio_handler_is_continuation(&op); pass(); } @@ -387,12 +387,12 @@ public: for(std::size_t i = 0; i < 100; ++i) { echo_server es{log, kind::async}; - boost::asio::io_context ioc; + net::io_context ioc; stream ws{ioc}; ws.next_layer().connect(es.stream()); ws.handshake("localhost", "/"); // too-big message frame indicates payload of 2^64-1 - boost::asio::write(ws.next_layer(), sbuf( + net::write(ws.next_layer(), sbuf( "\x81\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff")); multi_buffer b; error_code ec; @@ -406,13 +406,13 @@ public: testIssue807() { echo_server es{log}; - boost::asio::io_context ioc; + net::io_context ioc; stream ws{ioc}; ws.next_layer().connect(es.stream()); ws.handshake("localhost", "/"); ws.write(sbuf("Hello, world!")); char buf[4]; - boost::asio::mutable_buffer b{buf, 0}; + net::mutable_buffer b{buf, 0}; auto const n = ws.read_some(b); BEAST_EXPECT(n == 0); } @@ -428,7 +428,7 @@ public: { echo_server es{log}; multi_buffer b; - boost::asio::io_context ioc; + net::io_context ioc; stream ws{ioc}; ws.next_layer().connect(es.stream()); ws.handshake("localhost", "/"); @@ -478,18 +478,18 @@ public: #if 0 { echo_server es{log}; - boost::asio::io_context ioc; + net::io_context ioc; stream ws{ioc}; ws.set_option(pmd); ws.next_layer().connect(es.stream()); ws.handshake("localhost", "/"); // invalid 1-byte deflate block in frame - boost::asio::write(ws.next_layer(), sbuf( + net::write(ws.next_layer(), sbuf( "\xc1\x81\x3a\xa1\x74\x3b\x49")); } #endif { - boost::asio::io_context ioc; + net::io_context ioc; stream wsc{ioc}; stream wss{ioc}; wsc.set_option(pmd); @@ -503,7 +503,7 @@ public: BEAST_EXPECT(wsc.is_open()); BEAST_EXPECT(wss.is_open()); // invalid 1-byte deflate block in frame - boost::asio::write(wsc.next_layer(), sbuf( + net::write(wsc.next_layer(), sbuf( "\xc1\x81\x3a\xa1\x74\x3b\x49")); error_code ec; multi_buffer b; @@ -515,18 +515,18 @@ public: #if 0 { echo_server es{log, kind::async}; - boost::asio::io_context ioc; + net::io_context ioc; stream ws{ioc}; ws.set_option(pmd); ws.next_layer().connect(es.stream()); ws.handshake("localhost", "/"); // invalid 1-byte deflate block in frame - boost::asio::write(ws.next_layer(), sbuf( + net::write(ws.next_layer(), sbuf( "\xc1\x81\x3a\xa1\x74\x3b\x49")); } #endif { - boost::asio::io_context ioc; + net::io_context ioc; stream wsc{ioc}; stream wss{ioc}; wsc.set_option(pmd); @@ -540,7 +540,7 @@ public: BEAST_EXPECT(wsc.is_open()); BEAST_EXPECT(wss.is_open()); // invalid 1-byte deflate block in frame - boost::asio::write(wsc.next_layer(), sbuf( + net::write(wsc.next_layer(), sbuf( "\xc1\x81\x3a\xa1\x74\x3b\x49")); error_code ec; flat_buffer b; @@ -566,7 +566,7 @@ public: // read { - boost::asio::io_context ioc; + net::io_context ioc; stream wsc{ioc}; stream wss{ioc}; wsc.set_option(pmd); @@ -580,7 +580,7 @@ public: BEAST_EXPECT(wsc.is_open()); BEAST_EXPECT(wss.is_open()); // contains a deflate block with BFINAL set - boost::asio::write(wsc.next_layer(), sbuf( + net::write(wsc.next_layer(), sbuf( "\xc1\xf8\xd1\xe4\xcc\x3e\xda\xe4\xcc\x3e" "\x2b\x1e\x36\xc4\x2b\x1e\x36\xc4\x2b\x1e" "\x36\x3e\x35\xae\x4f\x54\x18\xae\x4f\x7b" @@ -602,7 +602,7 @@ public: // async read { - boost::asio::io_context ioc; + net::io_context ioc; stream wsc{ioc}; stream wss{ioc}; wsc.set_option(pmd); @@ -616,7 +616,7 @@ public: BEAST_EXPECT(wsc.is_open()); BEAST_EXPECT(wss.is_open()); // contains a deflate block with BFINAL set - boost::asio::write(wsc.next_layer(), sbuf( + net::write(wsc.next_layer(), sbuf( "\xc1\xf8\xd1\xe4\xcc\x3e\xda\xe4\xcc\x3e" "\x2b\x1e\x36\xc4\x2b\x1e\x36\xc4\x2b\x1e" "\x36\x3e\x35\xae\x4f\x54\x18\xae\x4f\x7b" @@ -642,10 +642,10 @@ public: void testMoveOnly() { - boost::asio::io_context ioc; + net::io_context ioc; stream ws{ioc}; ws.async_read_some( - boost::asio::mutable_buffer{}, + net::mutable_buffer{}, move_only_handler{}); } @@ -665,13 +665,13 @@ public: // breakpoint in asio_handler_invoke to make sure // it is instantiated. { - boost::asio::io_context ioc; - boost::asio::strand< - boost::asio::io_context::executor_type> s( + net::io_context ioc; + net::strand< + net::io_context::executor_type> s( ioc.get_executor()); stream ws{ioc}; flat_buffer b; - ws.async_read(b, boost::asio::bind_executor( + ws.async_read(b, net::bind_executor( s, copyable_handler{})); } } diff --git a/test/beast/websocket/stream.cpp b/test/beast/websocket/stream.cpp index c71a3f44..f5dfd94e 100644 --- a/test/beast/websocket/stream.cpp +++ b/test/beast/websocket/stream.cpp @@ -113,7 +113,7 @@ public: run() override { BOOST_STATIC_ASSERT(std::is_constructible< - stream, boost::asio::io_context&>::value); + stream, net::io_context&>::value); BOOST_STATIC_ASSERT(std::is_move_constructible< stream>::value); diff --git a/test/beast/websocket/stream_explicit.cpp b/test/beast/websocket/stream_explicit.cpp index 09ef0f21..a8bbe62d 100644 --- a/test/beast/websocket/stream_explicit.cpp +++ b/test/beast/websocket/stream_explicit.cpp @@ -9,7 +9,15 @@ // Test that header file is self-contained. #include + +#include #include -template class boost::beast::websocket::stream; -template class boost::beast::websocket::stream; +namespace boost { +namespace beast { + +template class websocket::stream; +template class websocket::stream; + +} // beast +} // boost diff --git a/test/beast/websocket/test.hpp b/test/beast/websocket/test.hpp index c59daa07..84157ec7 100644 --- a/test/beast/websocket/test.hpp +++ b/test/beast/websocket/test.hpp @@ -72,9 +72,9 @@ public: }; std::ostream& log_; - boost::asio::io_context ioc_; - boost::asio::executor_work_guard< - boost::asio::io_context::executor_type> work_; + net::io_context ioc_; + net::executor_work_guard< + net::io_context::executor_type> work_; static_buffer buffer_; test::stream ts_; std::thread t_; @@ -139,7 +139,7 @@ public: void async_close() { - boost::asio::post(ioc_, + net::post(ioc_, [&] { if(ws_.is_open()) @@ -178,7 +178,7 @@ public: #if 0 if( se.code() != error::closed && se.code() != error::failed && - se.code() != boost::asio::error::eof) + se.code() != net::error::eof) log_ << "echo_server: " << se.code().message() << std::endl; #endif } @@ -270,7 +270,7 @@ public: #if 0 if( ec != error::closed && ec != error::failed && - ec != boost::asio::error::eof) + ec != net::error::eof) log_ << "echo_server_async: " << ec.message() << @@ -384,7 +384,7 @@ public: class cbuf_helper { std::array v_; - boost::asio::const_buffer cb_; + net::const_buffer cb_; public: using value_type = decltype(cb_); @@ -420,10 +420,10 @@ public: template static - boost::asio::const_buffer + net::const_buffer sbuf(const char (&s)[N]) { - return boost::asio::const_buffer(&s[0], N-1); + return net::const_buffer(&s[0], N-1); } template< @@ -434,8 +434,8 @@ public: DynamicBuffer& buffer, ConstBufferSequence const& buffers) { - using boost::asio::buffer_copy; - using boost::asio::buffer_size; + using net::buffer_copy; + using net::buffer_size; buffer.commit(buffer_copy( buffer.prepare(buffer_size(buffers)), buffers)); @@ -443,7 +443,7 @@ public: template bool - run_until(boost::asio::io_context& ioc, + run_until(net::io_context& ioc, std::size_t limit, Pred&& pred) { for(std::size_t i = 0; i < limit; ++i) @@ -458,7 +458,7 @@ public: template bool run_until( - boost::asio::io_context& ioc, Pred&& pred) + net::io_context& ioc, Pred&& pred) { return run_until(ioc, 100, pred); } @@ -699,7 +699,7 @@ public: stream& ws, ConstBufferSequence const& buffers) const { - return boost::asio::write( + return net::write( ws.next_layer(), buffers); } }; @@ -708,11 +708,11 @@ public: class AsyncClient { - boost::asio::yield_context& yield_; + net::yield_context& yield_; public: explicit - AsyncClient(boost::asio::yield_context& yield) + AsyncClient(net::yield_context& yield) : yield_(yield) { } @@ -1009,7 +1009,7 @@ public: { error_code ec; auto const bytes_transferred = - boost::asio::async_write( + net::async_write( ws.next_layer(), buffers, yield_[ec]); if(ec) throw system_error{ec}; diff --git a/test/beast/websocket/utf8_checker.cpp b/test/beast/websocket/utf8_checker.cpp index e3ac8659..25f10748 100644 --- a/test/beast/websocket/utf8_checker.cpp +++ b/test/beast/websocket/utf8_checker.cpp @@ -86,7 +86,7 @@ public: // Autobahn 6.18.1 { utf8_checker u; - BEAST_EXPECT(! u.write(boost::asio::buffer("\xc1\xbf", 2))); + BEAST_EXPECT(! u.write(net::buffer("\xc1\xbf", 2))); } utf8_checker u; @@ -132,7 +132,7 @@ public: { { utf8_checker u; - BEAST_EXPECT(u.write(boost::asio::buffer("\xef\xbf\xbf", 3))); + BEAST_EXPECT(u.write(net::buffer("\xef\xbf\xbf", 3))); BEAST_EXPECT(u.finish()); } utf8_checker u; @@ -278,7 +278,7 @@ public: void testFourByteSequence() { - using boost::asio::const_buffer; + using net::const_buffer; utf8_checker u; std::uint8_t buf[4]; // First byte valid range 240-244 @@ -461,13 +461,13 @@ public: static std::size_t constexpr size = 3; std::size_t n = s.size(); buffers_suffix< - boost::asio::const_buffer> cb{ - boost::asio::const_buffer(s.data(), n)}; + net::const_buffer> cb{ + net::const_buffer(s.data(), n)}; multi_buffer b; while(n) { auto const amount = (std::min)(n, size); - b.commit(boost::asio::buffer_copy( + b.commit(net::buffer_copy( b.prepare(amount), cb)); cb.consume(amount); n -= amount; @@ -529,12 +529,12 @@ public: for(auto const& s : data) { std::size_t n = s.size(); - buffers_suffix cb{boost::asio::const_buffer(s.data(), n)}; + buffers_suffix cb{net::const_buffer(s.data(), n)}; multi_buffer b; while(n) { auto const amount = (std::min)(n, std::size_t(3)/*size*/); - b.commit(boost::asio::buffer_copy(b.prepare(amount), cb)); + b.commit(net::buffer_copy(b.prepare(amount), cb)); cb.consume(amount); n -= amount; } @@ -553,12 +553,12 @@ public: auto const& s = data[i]; std::size_t n = s.size(); - buffers_suffix cb{boost::asio::const_buffer(s.data(), n)}; + buffers_suffix cb{net::const_buffer(s.data(), n)}; multi_buffer b; while(n) { auto const amount = (std::min)(n, std::size_t(3)/*size*/); - b.commit(boost::asio::buffer_copy(b.prepare(amount), cb)); + b.commit(net::buffer_copy(b.prepare(amount), cb)); cb.consume(amount); n -= amount; } diff --git a/test/beast/websocket/write.cpp b/test/beast/websocket/write.cpp index 4109796e..eda04118 100644 --- a/test/beast/websocket/write.cpp +++ b/test/beast/websocket/write.cpp @@ -26,7 +26,7 @@ public: void doTestWrite(Wrap const& w) { - using boost::asio::buffer; + using net::buffer; permessage_deflate pmd; pmd.client_enable = false; @@ -47,7 +47,7 @@ public: catch(system_error const& se) { BEAST_EXPECTS( - se.code() == boost::asio::error::operation_aborted, + se.code() == net::error::operation_aborted, se.code().message()); } } @@ -71,7 +71,7 @@ public: [&](ws_type_t& ws) { ws.text(true); - w.write(ws, boost::asio::const_buffer{}); + w.write(ws, net::const_buffer{}); multi_buffer b; w.read(ws, b); BEAST_EXPECT(ws.got_text()); @@ -203,7 +203,7 @@ public: void doTestWriteDeflate(Wrap const& w) { - using boost::asio::buffer; + using net::buffer; permessage_deflate pmd; pmd.client_enable = true; @@ -254,7 +254,7 @@ public: void testWrite() { - using boost::asio::buffer; + using net::buffer; doTestWrite(SyncClient{}); doTestWrite(SyncClient{}); @@ -271,13 +271,13 @@ public: void testWriteSuspend() { - using boost::asio::buffer; + using net::buffer; // suspend on ping doFailLoop([&](test::fail_count& fc) { echo_server es{log}; - boost::asio::io_context ioc; + net::io_context ioc; stream ws{ioc, fc}; ws.next_layer().connect(es.stream()); ws.handshake("localhost", "/"); @@ -310,7 +310,7 @@ public: doFailLoop([&](test::fail_count& fc) { echo_server es{log}; - boost::asio::io_context ioc; + net::io_context ioc; stream ws{ioc, fc}; ws.next_layer().connect(es.stream()); ws.handshake("localhost", "/"); @@ -329,7 +329,7 @@ public: [&](error_code ec, std::size_t) { ++count; - if(ec != boost::asio::error::operation_aborted) + if(ec != net::error::operation_aborted) BOOST_THROW_EXCEPTION( system_error{ec}); }); @@ -342,7 +342,7 @@ public: doFailLoop([&](test::fail_count& fc) { echo_server es{log}; - boost::asio::io_context ioc; + net::io_context ioc; stream ws{ioc, fc}; ws.next_layer().connect(es.stream()); ws.handshake("localhost", "/"); @@ -384,7 +384,7 @@ public: doFailLoop([&](test::fail_count& fc) { echo_server es{log, kind::async_client}; - boost::asio::io_context ioc; + net::io_context ioc; stream ws{ioc, fc}; ws.next_layer().connect(es.stream()); es.async_handshake(); @@ -418,7 +418,7 @@ public: doFailLoop([&](test::fail_count& fc) { echo_server es{log, kind::async_client}; - boost::asio::io_context ioc; + net::io_context ioc; stream ws{ioc, fc}; ws.next_layer().connect(es.stream()); es.async_handshake(); @@ -452,7 +452,7 @@ public: doFailLoop([&](test::fail_count& fc) { echo_server es{log}; - boost::asio::io_context ioc; + net::io_context ioc; stream ws{ioc, fc}; ws.next_layer().connect(es.stream()); ws.handshake("localhost", "/"); @@ -484,7 +484,7 @@ public: doFailLoop([&](test::fail_count& fc) { echo_server es{log}; - boost::asio::io_context ioc; + net::io_context ioc; stream ws{ioc, fc}; ws.next_layer().connect(es.stream()); ws.handshake("localhost", "/"); @@ -516,7 +516,7 @@ public: doFailLoop([&](test::fail_count& fc) { echo_server es{log, kind::async}; - boost::asio::io_context ioc; + net::io_context ioc; stream ws{ioc, fc}; { permessage_deflate pmd; @@ -560,7 +560,7 @@ public: { echo_server es{log, i==1 ? kind::async : kind::sync}; - boost::asio::io_context ioc; + net::io_context ioc; stream ws{ioc}; ws.next_layer().connect(es.stream()); @@ -569,7 +569,7 @@ public: if(! BEAST_EXPECTS(! ec, ec.message())) break; ws.async_write_some(false, - boost::asio::const_buffer{}, + net::const_buffer{}, [&](error_code, std::size_t) { fail(); @@ -597,7 +597,7 @@ public: { echo_server es{log, i==1 ? kind::async : kind::sync}; - boost::asio::io_context ioc; + net::io_context ioc; stream ws{ioc}; ws.next_layer().connect(es.stream()); @@ -624,21 +624,21 @@ public: char buf[32]; stream ws{ioc_}; stream::write_some_op< - boost::asio::const_buffer, + net::const_buffer, handler> op{handler{}, ws, true, - boost::asio::const_buffer{ + net::const_buffer{ buf, sizeof(buf)}}; - using boost::asio::asio_handler_is_continuation; + using net::asio_handler_is_continuation; asio_handler_is_continuation(&op); } void testMoveOnly() { - boost::asio::io_context ioc; + net::io_context ioc; stream ws{ioc}; ws.async_write_some( - true, boost::asio::const_buffer{}, + true, net::const_buffer{}, move_only_handler{}); } @@ -658,14 +658,14 @@ public: // breakpoint in asio_handler_invoke to make sure // it is instantiated. { - boost::asio::io_context ioc; - boost::asio::strand< - boost::asio::io_context::executor_type> s( + net::io_context ioc; + net::strand< + net::io_context::executor_type> s( ioc.get_executor()); stream ws{ioc}; flat_buffer b; - ws.async_write(boost::asio::const_buffer{}, - boost::asio::bind_executor(s, + ws.async_write(net::const_buffer{}, + net::bind_executor(s, copyable_handler{})); } } diff --git a/test/bench/buffers/bench_buffers.cpp b/test/bench/buffers/bench_buffers.cpp index 71a72479..1548923e 100644 --- a/test/bench/buffers/bench_buffers.cpp +++ b/test/bench/buffers/bench_buffers.cpp @@ -224,10 +224,10 @@ public: ,[&](){ return do_hints (repeat, count, size); } ,[&](){ return do_random (repeat, count, size); } ); - do_trials("boost::asio::streambuf", trials, - [&](){ return do_prepares(repeat, count, size); } - ,[&](){ return do_hints (repeat, count, size); } - ,[&](){ return do_random (repeat, count, size); } + do_trials("net::streambuf", trials, + [&](){ return do_prepares(repeat, count, size); } + ,[&](){ return do_hints (repeat, count, size); } + ,[&](){ return do_random (repeat, count, size); } ); log << std::endl; } diff --git a/test/bench/parser/bench_parser.cpp b/test/bench/parser/bench_parser.cpp index 0650aee8..6a13b6d2 100644 --- a/test/bench/parser/bench_parser.cpp +++ b/test/bench/parser/bench_parser.cpp @@ -76,7 +76,7 @@ public: basic_parser& parser, error_code& ec) { - using boost::asio::buffer_size; + using net::buffer_size; beast::buffers_suffix< ConstBufferSequence> cb{buffers}; std::size_t used = 0; @@ -158,7 +158,7 @@ public: isRequest, bench_parser> { using mutable_buffers_type = - boost::asio::mutable_buffer; + net::mutable_buffer; void on_request_impl(verb, string_view, diff --git a/test/bench/parser/nodejs_parser.hpp b/test/bench/parser/nodejs_parser.hpp index a62c340e..818734bf 100644 --- a/test/bench/parser/nodejs_parser.hpp +++ b/test/bench/parser/nodejs_parser.hpp @@ -265,7 +265,7 @@ std::size_t nodejs_basic_parser::write( ConstBufferSequence const& buffers, error_code& ec) { - static_assert(boost::asio::is_const_buffer_sequence< + static_assert(net::is_const_buffer_sequence< ConstBufferSequence>::value, "ConstBufferSequence requirements not met"); std::size_t bytes_used = 0; diff --git a/test/bench/wsload/wsload.cpp b/test/bench/wsload/wsload.cpp index 8df6e47d..298c66fa 100644 --- a/test/bench/wsload/wsload.cpp +++ b/test/bench/wsload/wsload.cpp @@ -32,23 +32,22 @@ #include #include -namespace asio = boost::asio; -namespace ip = boost::asio::ip; -using tcp = boost::asio::ip::tcp; -namespace ws = boost::beast::websocket; -namespace ph = std::placeholders; -using error_code = boost::beast::error_code; +namespace beast = boost::beast; // from +namespace http = beast::http; // from +namespace websocket = beast::websocket; // from +namespace net = boost::asio; // from +using tcp = boost::asio::ip::tcp; // from class test_buffer { char data_[4096]; - boost::asio::const_buffer b_; + net::const_buffer b_; public: using const_iterator = - boost::asio::const_buffer const*; + net::const_buffer const*; - using value_type = boost::asio::const_buffer; + using value_type = net::const_buffer; test_buffer() : b_(data_, sizeof(data_)) @@ -101,7 +100,7 @@ public: }; void -fail(boost::system::error_code ec, char const* what) +fail(beast::error_code ec, char const* what) { std::cerr << what << ": " << ec.message() << "\n"; } @@ -109,13 +108,13 @@ fail(boost::system::error_code ec, char const* what) class connection : public std::enable_shared_from_this { - ws::stream ws_; + websocket::stream ws_; tcp::endpoint ep_; std::size_t messages_; report& rep_; test_buffer const& tb_; - asio::strand< - asio::io_context::executor_type> strand_; + net::strand< + net::io_context::executor_type> strand_; boost::beast::multi_buffer buffer_; std::mt19937_64 rng_; std::size_t count_ = 0; @@ -124,7 +123,7 @@ class connection public: connection( - asio::io_context& ioc, + net::io_context& ioc, tcp::endpoint const& ep, std::size_t messages, bool deflate, @@ -137,7 +136,7 @@ public: , tb_(tb) , strand_(ioc.get_executor()) { - ws::permessage_deflate pmd; + websocket::permessage_deflate pmd; pmd.client_enable = deflate; ws_.set_option(pmd); ws_.binary(true); @@ -157,12 +156,12 @@ public: alloc_.wrap(std::bind( &connection::on_connect, shared_from_this(), - ph::_1))); + std::placeholders::_1))); } private: void - on_connect(error_code ec) + on_connect(beast::error_code ec) { if(ec) return fail(ec, "on_connect"); @@ -173,11 +172,11 @@ private: alloc_.wrap(std::bind( &connection::on_handshake, shared_from_this(), - ph::_1))); + std::placeholders::_1))); } void - on_handshake(error_code ec) + on_handshake(beast::error_code ec) { if(ec) return fail(ec, "handshake"); @@ -189,17 +188,17 @@ private: do_write() { std::geometric_distribution dist{ - double(4) / boost::asio::buffer_size(tb_)}; + double(4) / net::buffer_size(tb_)}; ws_.async_write_some(true, boost::beast::buffers_prefix(dist(rng_), tb_), alloc_.wrap(std::bind( &connection::on_write, shared_from_this(), - ph::_1))); + std::placeholders::_1))); } void - on_write(error_code ec) + on_write(beast::error_code ec) { if(ec) return fail(ec, "write"); @@ -211,7 +210,7 @@ private: alloc_.wrap(std::bind( &connection::on_close, shared_from_this(), - ph::_1))); + std::placeholders::_1))); } void @@ -221,11 +220,11 @@ private: alloc_.wrap(std::bind( &connection::on_read, shared_from_this(), - ph::_1))); + std::placeholders::_1))); } void - on_read(error_code ec) + on_read(beast::error_code ec) { if(ec) return fail(ec, "read"); @@ -237,7 +236,7 @@ private: } void - on_close(error_code ec) + on_close(beast::error_code ec) { if(ec) return fail(ec, "close"); @@ -293,7 +292,7 @@ main(int argc, char** argv) return EXIT_FAILURE; } - auto const address = boost::asio::ip::make_address(argv[1]); + auto const address = net::ip::make_address(argv[1]); auto const port = static_cast(std::atoi(argv[2])); auto const trials = static_cast(std::atoi(argv[3])); auto const messages= static_cast(std::atoi(argv[4])); @@ -305,7 +304,7 @@ main(int argc, char** argv) for(auto i = trials; i != 0; --i) { report rep; - boost::asio::io_context ioc{1}; + net::io_context ioc{1}; for(auto j = workers; j; --j) { auto sp = diff --git a/test/doc/core_examples.cpp b/test/doc/core_examples.cpp index cc215b6f..5bd3d089 100644 --- a/test/doc/core_examples.cpp +++ b/test/doc/core_examples.cpp @@ -32,18 +32,18 @@ public: buf[2] = 0; buf[3] = 0; BEAST_EXPECT(boost::indeterminate(is_ssl_handshake( - boost::asio::buffer(buf, 0)))); + net::buffer(buf, 0)))); BEAST_EXPECT(boost::indeterminate(is_ssl_handshake( - boost::asio::buffer(buf, 1)))); + net::buffer(buf, 1)))); BEAST_EXPECT(boost::indeterminate(is_ssl_handshake( - boost::asio::buffer(buf, 2)))); + net::buffer(buf, 2)))); BEAST_EXPECT(boost::indeterminate(is_ssl_handshake( - boost::asio::buffer(buf, 3)))); + net::buffer(buf, 3)))); BEAST_EXPECT(is_ssl_handshake( - boost::asio::buffer(buf, 4))); + net::buffer(buf, 4))); buf[0] = 0; BEAST_EXPECT(! is_ssl_handshake( - boost::asio::buffer(buf, 1))); + net::buffer(buf, 1))); } void diff --git a/test/doc/core_snippets.cpp b/test/doc/core_snippets.cpp index 78f67cdf..92923c13 100644 --- a/test/doc/core_snippets.cpp +++ b/test/doc/core_snippets.cpp @@ -26,12 +26,12 @@ void fxx() // using namespace boost::beast; -boost::asio::io_context ioc; -auto work = boost::asio::make_work_guard(ioc); +net::io_context ioc; +auto work = net::make_work_guard(ioc); std::thread t{[&](){ ioc.run(); }}; error_code ec; -boost::asio::ip::tcp::socket sock{ioc}; +net::ip::tcp::socket sock{ioc}; //] boost::ignore_unused(ec); @@ -40,10 +40,10 @@ boost::asio::ip::tcp::socket sock{ioc}; //[snippet_core_2 char const* const host = "www.example.com"; -boost::asio::ip::tcp::resolver r{ioc}; -boost::asio::ip::tcp::socket stream{ioc}; +net::ip::tcp::resolver r{ioc}; +net::ip::tcp::socket stream{ioc}; auto const results = r.resolve(host, "http"); -boost::asio::connect(stream, results.begin(), results.end()); +net::connect(stream, results.begin(), results.end()); // At this point `stream` is a connected to a remote // host and may be used to perform stream operations. @@ -62,7 +62,7 @@ void write_string(SyncWriteStream& stream, string_view s) { static_assert(is_sync_write_stream::value, "SyncWriteStream requirements not met"); - boost::asio::write(stream, boost::asio::const_buffer(s.data(), s.size())); + net::write(stream, net::const_buffer(s.data(), s.size())); } //] diff --git a/test/doc/exemplars.cpp b/test/doc/exemplars.cpp index d45d36aa..0f5dc743 100644 --- a/test/doc/exemplars.cpp +++ b/test/doc/exemplars.cpp @@ -53,7 +53,7 @@ struct BodyWriter { public: /// The type of buffer returned by `get`. - using const_buffers_type = boost::asio::const_buffer; + using const_buffers_type = net::const_buffer; /** Construct the writer. @@ -164,7 +164,7 @@ struct BodyReader // The specification requires this to indicate "no error" ec = {}; - return boost::asio::buffer_size(buffers); + return net::buffer_size(buffers); } /** Called when the body is complete. diff --git a/test/doc/http_examples.cpp b/test/doc/http_examples.cpp index f9a684de..aead6ba3 100644 --- a/test/doc/http_examples.cpp +++ b/test/doc/http_examples.cpp @@ -201,7 +201,7 @@ public: }; error_code ec; custom_parser p; - p.put(boost::asio::buffer( + p.put(net::buffer( s.data(), s.size()), ec); BEAST_EXPECTS(! ec, ec.message()); } @@ -218,7 +218,7 @@ public: }; error_code ec; custom_parser p; - p.put(boost::asio::buffer( + p.put(net::buffer( s.data(), s.size()), ec); BEAST_EXPECTS(! ec, ec.message()); } @@ -309,7 +309,7 @@ public: auto const buf = [](string_view s) { - return boost::asio::const_buffer{ + return net::const_buffer{ s.data(), s.size()}; }; test::stream ts{ioc_}, tr{ioc_}; @@ -326,22 +326,22 @@ public: chunk_extensions exts; - boost::asio::write(ts, + net::write(ts, make_chunk(buf("First")), ec); exts.insert("quality", "1.0"); - boost::asio::write(ts, + net::write(ts, make_chunk(buf("Hello, world!"), exts), ec); exts.clear(); exts.insert("file", "abc.txt"); exts.insert("quality", "0.7"); - boost::asio::write(ts, + net::write(ts, make_chunk(buf("The Next Chunk"), std::move(exts)), ec); exts.clear(); exts.insert("last"); - boost::asio::write(ts, + net::write(ts, make_chunk(buf("Last one"), std::move(exts), std::allocator{}), ec); @@ -349,7 +349,7 @@ public: trailers.set(field::expires, "never"); trailers.set(field::content_md5, "f4a5c16584f03d90"); - boost::asio::write(ts, + net::write(ts, make_chunk_last( trailers, std::allocator{} diff --git a/test/doc/http_snippets.cpp b/test/doc/http_snippets.cpp index 8985fa12..53afcfab 100644 --- a/test/doc/http_snippets.cpp +++ b/test/doc/http_snippets.cpp @@ -26,20 +26,20 @@ namespace doc_http_snippets { //[http_snippet_17 // This function returns the buffer containing the next chunk body -boost::asio::const_buffer get_next_chunk_body(); +net::const_buffer get_next_chunk_body(); //] -boost::asio::const_buffer get_next_chunk_body() +net::const_buffer get_next_chunk_body() { return {nullptr, 0}; } void fxx() { - boost::asio::io_context ioc; - auto work = boost::asio::make_work_guard(ioc); + net::io_context ioc; + auto work = net::make_work_guard(ioc); std::thread t{[&](){ ioc.run(); }}; - boost::asio::ip::tcp::socket sock{ioc}; + net::ip::tcp::socket sock{ioc}; { //[http_snippet_2 @@ -160,12 +160,12 @@ void fxx() { write_header(sock, sr); // Now manually emit three chunks: - boost::asio::write(sock, make_chunk(get_next_chunk_body())); - boost::asio::write(sock, make_chunk(get_next_chunk_body())); - boost::asio::write(sock, make_chunk(get_next_chunk_body())); + net::write(sock, make_chunk(get_next_chunk_body())); + net::write(sock, make_chunk(get_next_chunk_body())); + net::write(sock, make_chunk(get_next_chunk_body())); // We are responsible for sending the last chunk: - boost::asio::write(sock, make_chunk_last()); + net::write(sock, make_chunk_last()); //] } @@ -180,18 +180,18 @@ void fxx() { // Write the next chunk with the chunk extensions // The implementation will make a copy of the extensions object, // so the caller does not need to manage lifetime issues. - boost::asio::write(sock, make_chunk(get_next_chunk_body(), ext)); + net::write(sock, make_chunk(get_next_chunk_body(), ext)); // Write the next chunk with the chunk extensions // The implementation will make a copy of the extensions object, storing the copy // using the custom allocator, so the caller does not need to manage lifetime issues. - boost::asio::write(sock, make_chunk(get_next_chunk_body(), ext, std::allocator{})); + net::write(sock, make_chunk(get_next_chunk_body(), ext, std::allocator{})); // Write the next chunk with the chunk extensions // The implementation allocates memory using the default allocator and takes ownership // of the extensions object, so the caller does not need to manage lifetime issues. // Note: ext is moved - boost::asio::write(sock, make_chunk(get_next_chunk_body(), std::move(ext))); + net::write(sock, make_chunk(get_next_chunk_body(), std::move(ext))); //] } @@ -199,7 +199,7 @@ void fxx() { //[http_snippet_20 // Manually specify the chunk extensions. // Some of the strings contain spaces and a period and must be quoted - boost::asio::write(sock, make_chunk(get_next_chunk_body(), + net::write(sock, make_chunk(get_next_chunk_body(), ";mp3" ";title=\"Danny Boy\"" ";artist=\"Fred E. Weatherly\"" @@ -221,8 +221,8 @@ void fxx() { // Serialize the header and two chunks response_serializer sr{res}; write_header(sock, sr); - boost::asio::write(sock, make_chunk(get_next_chunk_body())); - boost::asio::write(sock, make_chunk(get_next_chunk_body())); + net::write(sock, make_chunk(get_next_chunk_body())); + net::write(sock, make_chunk(get_next_chunk_body())); // Prepare the trailer fields trailer; @@ -232,7 +232,7 @@ void fxx() { // Emit the trailer in the last chunk. // The implementation will use the default allocator to create the storage for holding // the serialized fields. - boost::asio::write(sock, make_chunk_last(trailer)); + net::write(sock, make_chunk_last(trailer)); //] } @@ -241,7 +241,7 @@ void fxx() { // Use a custom allocator for serializing the last chunk fields trailer; trailer.set(field::approved, "yes"); - boost::asio::write(sock, make_chunk_last(trailer, std::allocator{})); + net::write(sock, make_chunk_last(trailer, std::allocator{})); //] } @@ -253,7 +253,7 @@ void fxx() { "Content-MD5: f4a5c16584f03d90\r\n" "Expires: never\r\n" "\r\n"; - boost::asio::write(sock, make_chunk_last(boost::asio::const_buffer{ext.data(), ext.size()})); + net::write(sock, make_chunk_last(net::const_buffer{ext.data(), ext.size()})); //] } @@ -272,18 +272,18 @@ void fxx() { auto const cb3 = get_next_chunk_body(); // Manually emit a chunk by first writing the chunk-size header with the correct size - boost::asio::write(sock, chunk_header{ - boost::asio::buffer_size(cb1) + - boost::asio::buffer_size(cb2) + - boost::asio::buffer_size(cb3)}); + net::write(sock, chunk_header{ + net::buffer_size(cb1) + + net::buffer_size(cb2) + + net::buffer_size(cb3)}); // And then output the chunk body in three pieces ("chunk the chunk") - boost::asio::write(sock, cb1); - boost::asio::write(sock, cb2); - boost::asio::write(sock, cb3); + net::write(sock, cb1); + net::write(sock, cb2); + net::write(sock, cb3); // When we go this deep, we are also responsible for the terminating CRLF - boost::asio::write(sock, chunk_crlf{}); + net::write(sock, chunk_crlf{}); //] } @@ -367,7 +367,7 @@ print_cxx14(message const& m) { ec.assign(0, ec.category()); std::cout << buffers(buffer); - sr.consume(boost::asio::buffer_size(buffer)); + sr.consume(net::buffer_size(buffer)); }); } while(! ec && ! sr.is_done()); @@ -394,7 +394,7 @@ struct lambda { ec.assign(0, ec.category()); std::cout << buffers(buffer); - sr.consume(boost::asio::buffer_size(buffer)); + sr.consume(net::buffer_size(buffer)); } }; @@ -435,7 +435,7 @@ split_print_cxx14(message const& m) { ec.assign(0, ec.category()); std::cout << buffers(buffer); - sr.consume(boost::asio::buffer_size(buffer)); + sr.consume(net::buffer_size(buffer)); }); } while(! sr.is_header_done()); @@ -449,7 +449,7 @@ split_print_cxx14(message const& m) { ec.assign(0, ec.category()); std::cout << buffers(buffer); - sr.consume(boost::asio::buffer_size(buffer)); + sr.consume(net::buffer_size(buffer)); }); } while(! ec && ! sr.is_done()); diff --git a/test/doc/websocket_snippets.cpp b/test/doc/websocket_snippets.cpp index 02c07ee2..5008334b 100644 --- a/test/doc/websocket_snippets.cpp +++ b/test/doc/websocket_snippets.cpp @@ -27,55 +27,55 @@ namespace doc_ws_snippets { void fxx() { -boost::asio::io_context ioc; -auto work = boost::asio::make_work_guard(ioc); +net::io_context ioc; +auto work = net::make_work_guard(ioc); std::thread t{[&](){ ioc.run(); }}; error_code ec; -boost::asio::ip::tcp::socket sock{ioc}; +net::ip::tcp::socket sock{ioc}; boost::ignore_unused(ec); { //[ws_snippet_2 - stream ws{ioc}; + stream ws{ioc}; //] } { //[ws_snippet_3 - stream ws{std::move(sock)}; + stream ws{std::move(sock)}; //] } { //[ws_snippet_4 - stream ws{sock}; + stream ws{sock}; //] //[ws_snippet_5 - ws.next_layer().shutdown(boost::asio::ip::tcp::socket::shutdown_send); + ws.next_layer().shutdown(net::ip::tcp::socket::shutdown_send); //] } { //[ws_snippet_6 std::string const host = "example.com"; - boost::asio::ip::tcp::resolver r{ioc}; - stream ws{ioc}; + net::ip::tcp::resolver r{ioc}; + stream ws{ioc}; auto const results = r.resolve(host, "ws"); - boost::asio::connect(ws.next_layer(), results.begin(), results.end()); + net::connect(ws.next_layer(), results.begin(), results.end()); //] } { //[ws_snippet_7 - boost::asio::ip::tcp::acceptor acceptor{ioc}; - stream ws{acceptor.get_executor().context()}; + net::ip::tcp::acceptor acceptor{ioc}; + stream ws{acceptor.get_executor().context()}; acceptor.accept(ws.next_layer()); //] } { - stream ws{ioc}; + stream ws{ioc}; //[ws_snippet_8 ws.handshake("localhost", "/"); //] @@ -121,7 +121,7 @@ boost::ignore_unused(ec); if(websocket::is_upgrade(req)) { // Construct the stream, transferring ownership of the socket - stream ws{std::move(sock)}; + stream ws{std::move(sock)}; // Clients SHOULD NOT begin sending WebSocket // frames until the server has provided a response. @@ -139,19 +139,19 @@ boost::ignore_unused(ec); } { - stream ws{ioc}; + stream ws{ioc}; //[ws_snippet_14 // Read into our buffer until we reach the end of the HTTP request. // No parsing takes place here, we are just accumulating data. - boost::asio::streambuf buffer; - boost::asio::read_until(sock, buffer, "\r\n\r\n"); + net::streambuf buffer; + net::read_until(sock, buffer, "\r\n\r\n"); // Now accept the connection, using the buffered data. ws.accept(buffer.data()); //] } { - stream ws{ioc}; + stream ws{ioc}; //[ws_snippet_15 // This DynamicBuffer will hold the received message multi_buffer buffer; @@ -176,7 +176,7 @@ boost::ignore_unused(ec); } { - stream ws{ioc}; + stream ws{ioc}; //[ws_snippet_16 // This DynamicBuffer will hold the received message multi_buffer buffer; @@ -202,7 +202,7 @@ boost::ignore_unused(ec); // This will cause the message to be broken up into multiple frames. for(;;) { - using boost::asio::buffer_size; + using net::buffer_size; if(buffer_size(cb) > 512) { // There are more than 512 bytes left to send, just @@ -232,7 +232,7 @@ boost::ignore_unused(ec); } { - stream ws{ioc}; + stream ws{ioc}; //[ws_snippet_17 ws.control_callback( [](frame_type kind, string_view payload) @@ -285,12 +285,12 @@ boost::ignore_unused(ec); // workaround for https://github.com/chriskohlhoff/asio/issues/112 #ifdef BOOST_MSVC //[ws_snippet_21 -void echo(stream& ws, - multi_buffer& buffer, boost::asio::yield_context yield) +void echo(stream& ws, + multi_buffer& buffer, net::yield_context yield) { ws.async_read(buffer, yield); std::future fut = - ws.async_write(buffer.data(), boost::asio::use_future); + ws.async_write(buffer.data(), net::use_future); } //] #endif @@ -379,30 +379,30 @@ namespace doc_wss_snippets { void fxx() { -boost::asio::io_context ioc; -auto work = boost::asio::make_work_guard(ioc); +net::io_context ioc; +auto work = net::make_work_guard(ioc); std::thread t{[&](){ ioc.run(); }}; error_code ec; -boost::asio::ip::tcp::socket sock{ioc}; +net::ip::tcp::socket sock{ioc}; { //[wss_snippet_2 - boost::asio::ssl::context ctx{boost::asio::ssl::context::sslv23}; - stream> wss{ioc, ctx}; + net::ssl::context ctx{net::ssl::context::sslv23}; + stream> wss{ioc, ctx}; //] } { //[wss_snippet_3 - boost::asio::ip::tcp::endpoint ep; - boost::asio::ssl::context ctx{boost::asio::ssl::context::sslv23}; - stream> ws{ioc, ctx}; + net::ip::tcp::endpoint ep; + net::ssl::context ctx{net::ssl::context::sslv23}; + stream> ws{ioc, ctx}; // connect the underlying TCP/IP socket ws.next_layer().next_layer().connect(ep); // perform SSL handshake - ws.next_layer().handshake(boost::asio::ssl::stream_base::client); + ws.next_layer().handshake(net::ssl::stream_base::client); // perform WebSocket handshake ws.handshake("localhost", "/"); diff --git a/test/extras/include/boost/beast/test/sig_wait.hpp b/test/extras/include/boost/beast/test/sig_wait.hpp index 847dc95b..3e8de714 100644 --- a/test/extras/include/boost/beast/test/sig_wait.hpp +++ b/test/extras/include/boost/beast/test/sig_wait.hpp @@ -21,8 +21,8 @@ inline void sig_wait() { - boost::asio::io_context ioc; - boost::asio::signal_set signals( + net::io_context ioc; + net::signal_set signals( ioc, SIGINT, SIGTERM); signals.async_wait( [&](boost::system::error_code const&, int) diff --git a/test/extras/include/boost/beast/test/websocket.hpp b/test/extras/include/boost/beast/test/websocket.hpp index a88bae3c..07d64cfc 100644 --- a/test/extras/include/boost/beast/test/websocket.hpp +++ b/test/extras/include/boost/beast/test/websocket.hpp @@ -28,9 +28,9 @@ namespace test { class ws_echo_server { std::ostream& log_; - boost::asio::io_context ioc_; - boost::asio::executor_work_guard< - boost::asio::io_context::executor_type> work_; + net::io_context ioc_; + net::executor_work_guard< + net::io_context::executor_type> work_; multi_buffer buffer_; test::stream ts_; std::thread t_; @@ -102,7 +102,7 @@ public: void async_close() { - boost::asio::post(ioc_, + net::post(ioc_, [&] { if(ws_.is_open()) @@ -141,7 +141,7 @@ private: #if 0 if( se.code() != error::closed && se.code() != error::failed && - se.code() != boost::asio::error::eof) + se.code() != net::error::eof) log_ << "ws_echo_server: " << se.code().message() << std::endl; #endif } @@ -233,7 +233,7 @@ private: #if 0 if( ec != error::closed && ec != error::failed && - ec != boost::asio::error::eof) + ec != net::error::eof) log_ << "echo_server_async: " << ec.message() << diff --git a/test/extras/include/boost/beast/test/yield_to.hpp b/test/extras/include/boost/beast/test/yield_to.hpp index 2893b547..065cc906 100644 --- a/test/extras/include/boost/beast/test/yield_to.hpp +++ b/test/extras/include/boost/beast/test/yield_to.hpp @@ -32,11 +32,11 @@ namespace test { class enable_yield_to { protected: - boost::asio::io_context ioc_; + net::io_context ioc_; private: - boost::asio::executor_work_guard< - boost::asio::io_context::executor_type> work_; + net::executor_work_guard< + net::io_context::executor_type> work_; std::vector threads_; std::mutex m_; std::condition_variable cv_; @@ -45,7 +45,7 @@ private: public: /// The type of yield context passed to functions. using yield_context = - boost::asio::yield_context; + net::yield_context; explicit enable_yield_to(std::size_t concurrency = 1) @@ -65,7 +65,7 @@ public: } /// Return the `io_context` associated with the object - boost::asio::io_context& + net::io_context& get_io_service() { return ioc_; @@ -120,7 +120,7 @@ void enable_yield_to:: spawn(F0&& f, FN&&... fn) { - boost::asio::spawn(ioc_, + net::spawn(ioc_, [&](yield_context yield) { f(yield);