rippled
Public Types | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
ripple::SSLHTTPDownloader Class Referenceabstract

Provides an asynchronous HTTPS file downloader. More...

Inheritance diagram for ripple::SSLHTTPDownloader:
Inheritance graph
[legend]
Collaboration diagram for ripple::SSLHTTPDownloader:
Collaboration graph
[legend]

Public Types

using error_code = boost::system::error_code
 

Public Member Functions

 SSLHTTPDownloader (boost::asio::io_service &io_service, beast::Journal j, Config const &config, bool isPaused=false)
 
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)
 
void onStop ()
 
virtual ~SSLHTTPDownloader ()=default
 
shared_from_this (T... args)
 
weak_from_this (T... args)
 

Protected Types

using parser = boost::beast::http::basic_parser< false >
 

Protected Member Functions

bool fail (boost::filesystem::path dstPath, std::function< void(boost::filesystem::path)> const &complete, boost::system::error_code const &ec, std::string const &errMsg, std::shared_ptr< parser > parser=nullptr)
 

Protected Attributes

const beast::Journal j_
 

Private Member Functions

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, boost::asio::yield_context yield)
 
virtual std::shared_ptr< parsergetParser (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
 
virtual void closeBody (std::shared_ptr< parser > p)=0
 
virtual uint64_t size (std::shared_ptr< parser > p)=0
 

Private Attributes

HTTPClientSSLContext ssl_ctx_
 
boost::asio::io_service::strand strand_
 
boost::optional< boost::asio::ssl::stream< boost::asio::ip::tcp::socket > > stream_
 
boost::beast::flat_buffer read_buf_
 
std::atomic< bool > isStopped_
 
bool sessionActive_
 
std::mutex m_
 
std::condition_variable c_
 

Detailed Description

Provides an asynchronous HTTPS file downloader.

Definition at line 44 of file SSLHTTPDownloader.h.

Member Typedef Documentation

◆ error_code

using ripple::SSLHTTPDownloader::error_code = boost::system::error_code

Definition at line 47 of file SSLHTTPDownloader.h.

◆ parser

using ripple::SSLHTTPDownloader::parser = boost::beast::http::basic_parser<false>
protected

Definition at line 70 of file SSLHTTPDownloader.h.

Constructor & Destructor Documentation

◆ SSLHTTPDownloader()

ripple::SSLHTTPDownloader::SSLHTTPDownloader ( boost::asio::io_service &  io_service,
beast::Journal  j,
Config const &  config,
bool  isPaused = false 
)

Definition at line 25 of file SSLHTTPDownloader.cpp.

◆ ~SSLHTTPDownloader()

virtual ripple::SSLHTTPDownloader::~SSLHTTPDownloader ( )
virtualdefault

Member Function Documentation

◆ download()

bool ripple::SSLHTTPDownloader::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 
)

Definition at line 39 of file SSLHTTPDownloader.cpp.

◆ onStop()

void ripple::SSLHTTPDownloader::onStop ( )

Definition at line 77 of file SSLHTTPDownloader.cpp.

◆ fail()

bool ripple::SSLHTTPDownloader::fail ( boost::filesystem::path  dstPath,
std::function< void(boost::filesystem::path)> const &  complete,
boost::system::error_code const &  ec,
std::string const &  errMsg,
std::shared_ptr< parser parser = nullptr 
)
protected

Definition at line 340 of file SSLHTTPDownloader.cpp.

◆ do_session()

void ripple::SSLHTTPDownloader::do_session ( std::string  host,
std::string  port,
std::string  target,
int  version,
boost::filesystem::path  dstPath,
std::function< void(boost::filesystem::path)>  complete,
boost::asio::yield_context  yield 
)
private

Definition at line 91 of file SSLHTTPDownloader.cpp.

◆ getParser()

virtual std::shared_ptr<parser> ripple::SSLHTTPDownloader::getParser ( boost::filesystem::path  dstPath,
std::function< void(boost::filesystem::path)>  complete,
boost::system::error_code &  ec 
)
privatepure virtual

Implemented in ripple::DatabaseDownloader.

◆ checkPath()

virtual bool ripple::SSLHTTPDownloader::checkPath ( boost::filesystem::path const &  dstPath)
privatepure virtual

Implemented in ripple::DatabaseDownloader.

◆ closeBody()

virtual void ripple::SSLHTTPDownloader::closeBody ( std::shared_ptr< parser p)
privatepure virtual

Implemented in ripple::DatabaseDownloader.

◆ size()

virtual uint64_t ripple::SSLHTTPDownloader::size ( std::shared_ptr< parser p)
privatepure virtual

Implemented in ripple::DatabaseDownloader.

Member Data Documentation

◆ j_

const beast::Journal ripple::SSLHTTPDownloader::j_
protected

Definition at line 72 of file SSLHTTPDownloader.h.

◆ ssl_ctx_

HTTPClientSSLContext ripple::SSLHTTPDownloader::ssl_ctx_
private

Definition at line 83 of file SSLHTTPDownloader.h.

◆ strand_

boost::asio::io_service::strand ripple::SSLHTTPDownloader::strand_
private

Definition at line 84 of file SSLHTTPDownloader.h.

◆ stream_

boost::optional<boost::asio::ssl::stream<boost::asio::ip::tcp::socket> > ripple::SSLHTTPDownloader::stream_
private

Definition at line 86 of file SSLHTTPDownloader.h.

◆ read_buf_

boost::beast::flat_buffer ripple::SSLHTTPDownloader::read_buf_
private

Definition at line 87 of file SSLHTTPDownloader.h.

◆ isStopped_

std::atomic<bool> ripple::SSLHTTPDownloader::isStopped_
private

Definition at line 88 of file SSLHTTPDownloader.h.

◆ sessionActive_

bool ripple::SSLHTTPDownloader::sessionActive_
private

Definition at line 89 of file SSLHTTPDownloader.h.

◆ m_

std::mutex ripple::SSLHTTPDownloader::m_
private

Definition at line 90 of file SSLHTTPDownloader.h.

◆ c_

std::condition_variable ripple::SSLHTTPDownloader::c_
private

Definition at line 91 of file SSLHTTPDownloader.h.