From cc1cd1bbbdef4a9d39b650b41699d7d8fa4bc0e1 Mon Sep 17 00:00:00 2001 From: jamescoxon Date: Sat, 29 Jul 2017 20:38:51 +0000 Subject: [PATCH] updated to latest beast directory including moving submodule link url and also porting commands to latest code --- .gitmodules | 2 +- beast | 2 +- cryptopp | 2 +- miniupnp | 2 +- rai/node/node.cpp | 48 +++++++++++++++++++++++++---------------------- rai/node/rpc.cpp | 15 ++++++++------- rai/node/rpc.hpp | 11 ++++++----- 7 files changed, 44 insertions(+), 38 deletions(-) diff --git a/.gitmodules b/.gitmodules index 86654af9..67adefc9 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,6 @@ [submodule "beast"] path = beast - url = https://github.com/vinniefalco/Beast.git + url = https://github.com/boostorg/beast.git [submodule "miniupnp"] path = miniupnp url = https://github.com/miniupnp/miniupnp.git diff --git a/beast b/beast index 663c275f..c7b830f3 160000 --- a/beast +++ b/beast @@ -1 +1 @@ -Subproject commit 663c275fc16c2b5e075b96bbe91467f83256df5c +Subproject commit c7b830f37f8adc0df63d41ff4d31395ab704516b diff --git a/cryptopp b/cryptopp index 32f715f1..ed4c345c 160000 --- a/cryptopp +++ b/cryptopp @@ -1 +1 @@ -Subproject commit 32f715f1d723e2bbb78b44fa9e167da64214e2e6 +Subproject commit ed4c345ce86aad98c38fac120569eb9406fbfc37 diff --git a/miniupnp b/miniupnp index 5923d5de..e24d7eca 160000 --- a/miniupnp +++ b/miniupnp @@ -1 +1 @@ -Subproject commit 5923d5de6ffd7960b9362f46735cbb0a6b738adf +Subproject commit e24d7eca28022b959b331b08e6918b58b303c1cf diff --git a/rai/node/node.cpp b/rai/node/node.cpp index 87f67dc1..0bd46071 100755 --- a/rai/node/node.cpp +++ b/rai/node/node.cpp @@ -1119,31 +1119,33 @@ warmed_up (0) { if (!ec) { - auto req (std::make_shared > ()); - req->method ("POST"); + auto req (std::make_shared > ()); + req->method (boost::beast::http::verb::post); req->target (*target); req->version = 11; - req->fields.replace("Host", address); + req->insert(boost::beast::http::field::host, address); req->body = *body; - beast::http::prepare (*req); - beast::http::async_write (*sock, *req, [node_l, sock, address, port, req] (boost::system::error_code & ec) + //req->prepare (*req); + //boost::beast::http::prepare(req); + req->prepare_payload(); + boost::beast::http::async_write (*sock, *req, [node_l, sock, address, port, req] (boost::system::error_code const & ec) { if (!ec) { - auto sb (std::make_shared ()); - auto resp (std::make_shared > ()); - beast::http::async_read (*sock, *sb, *resp, [node_l, sb, resp, sock, address, port] (boost::system::error_code & ec) + auto sb (std::make_shared ()); + auto resp (std::make_shared > ()); + boost::beast::http::async_read (*sock, *sb, *resp, [node_l, sb, resp, sock, address, port] (boost::system::error_code const & ec) { if (!ec) { - if (resp->status == 200) + if (resp->result() == boost::beast::http::status::ok) { } else { if (node_l->config.logging.callback_logging ()) { - BOOST_LOG (node_l->log) << boost::str (boost::format ("Callback to %1%:%2% failed with status: %3%") % address % port % resp->status); + BOOST_LOG (node_l->log) << boost::str (boost::format ("Callback to %1%:%2% failed with status: %3%") % address % port % resp->result()); } } } @@ -1837,8 +1839,8 @@ socket (service_a) } boost::asio::ip::address address; uint16_t port; -beast::flat_buffer buffer; -beast::http::response response; +boost::beast::flat_buffer buffer; +boost::beast::http::response response; boost::asio::ip::tcp::socket socket; }; class distributed_work : public std::enable_shared_from_this @@ -1881,21 +1883,22 @@ void start () boost::property_tree::write_json (ostream, request); request_string = ostream.str (); } - beast::http::request request; - request.method ("POST"); + boost::beast::http::request request; + request.method (boost::beast::http::verb::post); request.target ("/"); request.version = 11; request.body = request_string; - beast::http::prepare (request); - beast::http::async_write (connection->socket, request, [this_l, connection] (boost::system::error_code const & ec) + //boost::beast::http::prepare (request); + request.prepare_payload(); + boost::beast::http::async_write (connection->socket, request, [this_l, connection] (boost::system::error_code const & ec) { if (!ec) { - beast::http::async_read (connection->socket, connection->buffer, connection->response, [this_l, connection] (boost::system::error_code const & ec) + boost::beast::http::async_read (connection->socket, connection->buffer, connection->response, [this_l, connection] (boost::system::error_code const & ec) { if (!ec) { - if (connection->response.status == 200) + if (connection->response.result() == boost::beast::http::status::ok) { this_l->success (connection->response.body, connection->address); } @@ -1952,14 +1955,15 @@ void stop () boost::property_tree::write_json (ostream, request); request_string = ostream.str (); } - beast::http::request request; - request.method ("POST"); + boost::beast::http::request request; + request.method (boost::beast::http::verb::post); request.target ("/"); request.version = 11; request.body = request_string; - beast::http::prepare (request); + //boost::beast::http::prepare (request); + request.prepare_payload(); auto socket (std::make_shared (this_l->node->network.service)); - beast::http::async_write (*socket, request, [socket] (boost::system::error_code const & ec) + boost::beast::http::async_write (*socket, request, [socket] (boost::system::error_code const & ec) { }); }); diff --git a/rai/node/rpc.cpp b/rai/node/rpc.cpp index 7764a4b9..69325cb2 100755 --- a/rai/node/rpc.cpp +++ b/rai/node/rpc.cpp @@ -2387,7 +2387,7 @@ socket (node_a.network.service) void rai::rpc_connection::parse_connection () { auto this_l (shared_from_this ()); - beast::http::async_read (socket, buffer, request, [this_l] (boost::system::error_code const & ec) + boost::beast::http::async_read (socket, buffer, request, [this_l] (boost::system::error_code const & ec) { if (!ec) { @@ -2401,13 +2401,14 @@ void rai::rpc_connection::parse_connection () boost::property_tree::write_json (ostream, tree_a); ostream.flush (); auto body (ostream.str ()); - this_l->res.fields.insert ("content-type", "application/json"); - this_l->res.fields.insert ("Access-Control-Allow-Origin", "*"); - this_l->res.status = 200; + this_l->res.set ("content-type", "application/json"); + this_l->res.set ("Access-Control-Allow-Origin", "*"); + this_l->res.result(boost::beast::http::status::ok); this_l->res.body = body; this_l->res.version = version; - beast::http::prepare (this_l->res); - beast::http::async_write (this_l->socket, this_l->res, [this_l] (boost::system::error_code const & ec) + this_l->res.prepare_payload(); + //boost::beast::http::prepare (this_l->res); + boost::beast::http::async_write (this_l->socket, this_l->res, [this_l] (boost::system::error_code const & ec) { }); if (this_l->node->config.logging.log_rpc ()) @@ -2415,7 +2416,7 @@ void rai::rpc_connection::parse_connection () BOOST_LOG (this_l->node->log) << boost::str (boost::format ("RPC request %2% completed in: %1% microseconds") % std::chrono::duration_cast (std::chrono::system_clock::now () - start).count () % boost::io::group (std::hex, std::showbase, reinterpret_cast (this_l.get ()))); } }); - if (this_l->request.method () == "POST") + if (this_l->request.method () == boost::beast::http::verb::post) { auto handler (std::make_shared (*this_l->node, this_l->rpc, this_l->request.body, response_handler)); handler->process_request (); diff --git a/rai/node/rpc.hpp b/rai/node/rpc.hpp index 7cc8d98d..a0d809f4 100644 --- a/rai/node/rpc.hpp +++ b/rai/node/rpc.hpp @@ -2,8 +2,9 @@ #include -#include -#include +//#include +//#include +#include #include #include @@ -63,9 +64,9 @@ public: std::shared_ptr node; rai::rpc & rpc; boost::asio::ip::tcp::socket socket; - beast::flat_buffer buffer; - beast::http::request request; - beast::http::response res; + boost::beast::flat_buffer buffer; + boost::beast::http::request request; + boost::beast::http::response res; }; class payment_observer : public std::enable_shared_from_this {