20#ifndef RIPPLE_APP_MISC_DETAIL_WORKBASE_H_INCLUDED
21#define RIPPLE_APP_MISC_DETAIL_WORKBASE_H_INCLUDED
23#include <xrpld/app/misc/detail/Work.h>
25#include <xrpl/basics/random.h>
26#include <xrpl/protocol/BuildInfo.h>
28#include <boost/asio.hpp>
29#include <boost/beast/core/multi_buffer.hpp>
30#include <boost/beast/http/empty_body.hpp>
31#include <boost/beast/http/read.hpp>
32#include <boost/beast/http/write.hpp>
54 boost::beast::http::request<boost::beast::http::empty_body>;
60 boost::asio::io_service&
ios_;
75 boost::asio::io_service& ios,
84 return *
static_cast<Impl*
>(
this);
123 boost::asio::io_service& ios,
135 , lastEndpoint_{lastEndpoint}
136 , lastStatus_(lastStatus)
154 if (!strand_.running_in_this_thread())
158 resolver_.async_resolve(
163 impl().shared_from_this(),
164 std::placeholders::_1,
165 std::placeholders::_2)));
172 if (!strand_.running_in_this_thread())
174 return ios_.post(strand_.wrap(
189 cb_(ec, lastEndpoint_, std::move(res_));
201 boost::asio::async_connect(
206 impl().shared_from_this(),
207 std::placeholders::_1,
208 std::placeholders::_2)));
215 lastEndpoint_ = endpoint;
220 impl().onConnect(ec);
227 req_.method(boost::beast::http::verb::get);
228 req_.target(path_.empty() ?
"/" : path_);
230 req_.set(
"Host", host_ +
":" + port_);
232 req_.prepare_payload();
233 boost::beast::http::async_write(
238 impl().shared_from_this(),
239 std::placeholders::_1)));
249 boost::beast::http::async_read(
255 impl().shared_from_this(),
256 std::placeholders::_1)));
267 XRPL_ASSERT(cb_,
"ripple::detail::WorkBase::onResponse : callback is set");
268 cb_(ec, lastEndpoint_, std::move(res_));
276 if (socket_.is_open())
279 socket_.shutdown(boost::asio::socket_base::shutdown_send, ec);
boost::asio::io_service & ios_
endpoint_type lastEndpoint_
boost::asio::ip::tcp::resolver::results_type results_type
boost::beast::http::request< boost::beast::http::empty_body > request_type
void onResolve(error_code const &ec, results_type results)
void onRequest(error_code const &ec)
boost::asio::ip::tcp::socket socket_type
boost::asio::io_service::strand strand_
void onResponse(error_code const &ec)
boost::asio::ip::tcp::endpoint endpoint_type
boost::asio::ip::tcp::resolver resolver_type
boost::system::error_code error_code
boost::beast::multi_buffer readBuf_
void onConnect(error_code const &ec, endpoint_type const &endpoint)
WorkBase(std::string const &host, std::string const &path, std::string const &port, boost::asio::io_service &ios, endpoint_type const &lastEndpoint, bool lastStatus, callback_type cb)
void fail(error_code const &ec)
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(ripple::TokenCodecErrc e)