20 #ifndef RIPPLE_NET_HTTPDOWNLOADER_H_INCLUDED
21 #define RIPPLE_NET_HTTPDOWNLOADER_H_INCLUDED
23 #include <ripple/basics/Log.h>
24 #include <ripple/core/Config.h>
25 #include <ripple/net/HTTPStream.h>
27 #include <boost/asio/connect.hpp>
28 #include <boost/asio/io_service.hpp>
29 #include <boost/asio/ip/tcp.hpp>
30 #include <boost/asio/spawn.hpp>
31 #include <boost/asio/ssl/error.hpp>
32 #include <boost/asio/ssl/stream.hpp>
33 #include <boost/beast/core.hpp>
34 #include <boost/beast/http.hpp>
35 #include <boost/beast/version.hpp>
36 #include <boost/filesystem.hpp>
55 boost::filesystem::path
const& dstPath,
74 boost::asio::io_service& io_service,
78 using parser = boost::beast::http::basic_parser<false>;
84 boost::filesystem::path dstPath,
85 boost::system::error_code
const& ec,
107 boost::filesystem::path dstPath,
110 boost::asio::yield_context yield);
114 boost::filesystem::path dstPath,
116 boost::system::error_code& ec) = 0;
119 checkPath(boost::filesystem::path
const& dstPath) = 0;
virtual std::shared_ptr< parser > getParser(boost::filesystem::path dstPath, std::function< void(boost::filesystem::path)> complete, boost::system::error_code &ec)=0
virtual bool checkPath(boost::filesystem::path const &dstPath)=0
HTTPDownloader(boost::asio::io_service &io_service, Config const &config, beast::Journal j)
std::condition_variable c_
boost::beast::flat_buffer read_buf_
virtual void closeBody(std::shared_ptr< parser > p)=0
std::atomic< bool > stop_
std::unique_ptr< HTTPStream > stream_
void fail(boost::filesystem::path dstPath, boost::system::error_code const &ec, std::string const &errMsg, std::shared_ptr< parser > parser)
A generic endpoint for log messages.
bool sessionIsActive() const
boost::system::error_code error_code
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
bool download(std::string const &host, std::string const &port, std::string const &target, int version, boost::filesystem::path const &dstPath, std::function< void(boost::filesystem::path)> complete, bool ssl=true)
virtual ~HTTPDownloader()=default
Provides an asynchronous HTTP[S] file downloader.
boost::beast::http::basic_parser< false > parser
void do_session(std::string host, std::string port, std::string target, int version, boost::filesystem::path dstPath, std::function< void(boost::filesystem::path)> complete, bool ssl, boost::asio::yield_context yield)
virtual uint64_t size(std::shared_ptr< parser > p)=0
boost::asio::io_service::strand strand_