3#include <xrpld/app/misc/detail/Work.h>
5#include <xrpl/basics/random.h>
6#include <xrpl/protocol/BuildInfo.h>
8#include <boost/asio.hpp>
9#include <boost/asio/strand.hpp>
10#include <boost/beast/core/multi_buffer.hpp>
11#include <boost/beast/http/empty_body.hpp>
12#include <boost/beast/http/read.hpp>
13#include <boost/beast/http/write.hpp>
33 using request_type = boost::beast::http::request<boost::beast::http::empty_body>;
39 boost::asio::io_context&
ios_;
40 boost::asio::strand<boost::asio::io_context::executor_type>
strand_;
54 boost::asio::io_context& ios,
63 return *
static_cast<Impl*
>(
this);
102 boost::asio::io_context& ios,
111 , strand_(
boost::asio::make_strand(ios))
114 , lastEndpoint_{lastEndpoint}
115 , lastStatus_(lastStatus)
123 cb_(
make_error_code(boost::system::errc::not_a_socket), lastEndpoint_, std::move(res_));
131 if (!strand_.running_in_this_thread())
132 return boost::asio::post(
135 resolver_.async_resolve(
138 boost::asio::bind_executor(
147 if (!strand_.running_in_this_thread())
149 return boost::asio::post(
166 cb_(ec, lastEndpoint_, std::move(res_));
178 boost::asio::async_connect(
181 boost::asio::bind_executor(
190 lastEndpoint_ = endpoint;
195 impl().onConnect(ec);
202 req_.method(boost::beast::http::verb::get);
203 req_.target(path_.empty() ?
"/" : path_);
205 req_.set(
"Host", host_ +
":" + port_);
207 req_.prepare_payload();
208 boost::beast::http::async_write(
211 boost::asio::bind_executor(
222 boost::beast::http::async_read(
226 boost::asio::bind_executor(
238 XRPL_ASSERT(cb_,
"xrpl::detail::WorkBase::onResponse : callback is set");
239 cb_(ec, lastEndpoint_, std::move(res_));
247 if (socket_.is_open())
250 socket_.shutdown(boost::asio::socket_base::shutdown_send, ec);
void fail(error_code const &ec)
endpoint_type lastEndpoint_
boost::beast::http::request< boost::beast::http::empty_body > request_type
void onResolve(error_code const &ec, results_type results)
boost::asio::ip::tcp::endpoint endpoint_type
boost::system::error_code error_code
boost::asio::ip::tcp::resolver::results_type results_type
void onRequest(error_code const &ec)
boost::asio::ip::tcp::socket socket_type
void onConnect(error_code const &ec, endpoint_type const &endpoint)
boost::asio::strand< boost::asio::io_context::executor_type > strand_
void onResponse(error_code const &ec)
boost::beast::multi_buffer readBuf_
WorkBase(std::string const &host, std::string const &path, std::string const &port, boost::asio::io_context &ios, endpoint_type const &lastEndpoint, bool lastStatus, callback_type cb)
boost::asio::io_context & ios_
boost::asio::ip::tcp::resolver resolver_type
std::string const & getFullVersionString()
Full server version string.
boost::beast::http::response< boost::beast::http::string_body > response_type
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
std::error_code make_error_code(xrpl::TokenCodecErrc e)