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

Provides an asynchronous HTTP[S] file downloader. More...

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

Public Types

using error_code = boost::system::error_code
 

Public Member Functions

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)
 
void stop ()
 
virtual ~HTTPDownloader ()=default
 
bool sessionIsActive () const
 
bool isStopping () const
 
shared_from_this (T... args)
 
weak_from_this (T... args)
 

Protected Types

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

Protected Member Functions

 HTTPDownloader (boost::asio::io_service &io_service, Config const &config, beast::Journal j)
 
void fail (boost::filesystem::path dstPath, boost::system::error_code const &ec, std::string const &errMsg, std::shared_ptr< parser > parser)
 

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, bool ssl, 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

Config const & config_
 
boost::asio::io_service::strand strand_
 
std::unique_ptr< HTTPStreamstream_
 
boost::beast::flat_buffer read_buf_
 
std::atomic< bool > stop_
 
std::mutex m_
 
bool sessionActive_
 
std::condition_variable c_
 

Detailed Description

Provides an asynchronous HTTP[S] file downloader.

Definition at line 44 of file HTTPDownloader.h.

Member Typedef Documentation

◆ error_code

using ripple::HTTPDownloader::error_code = boost::system::error_code

Definition at line 47 of file HTTPDownloader.h.

◆ parser

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

Definition at line 78 of file HTTPDownloader.h.

Constructor & Destructor Documentation

◆ ~HTTPDownloader()

virtual ripple::HTTPDownloader::~HTTPDownloader ( )
virtualdefault

◆ HTTPDownloader()

ripple::HTTPDownloader::HTTPDownloader ( boost::asio::io_service &  io_service,
Config const &  config,
beast::Journal  j 
)
protected

Definition at line 25 of file HTTPDownloader.cpp.

Member Function Documentation

◆ download()

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

Definition at line 38 of file HTTPDownloader.cpp.

◆ stop()

void ripple::HTTPDownloader::stop ( )

Definition at line 284 of file HTTPDownloader.cpp.

◆ sessionIsActive()

bool ripple::HTTPDownloader::sessionIsActive ( ) const

Definition at line 297 of file HTTPDownloader.cpp.

◆ isStopping()

bool ripple::HTTPDownloader::isStopping ( ) const

Definition at line 304 of file HTTPDownloader.cpp.

◆ fail()

void ripple::HTTPDownloader::fail ( boost::filesystem::path  dstPath,
boost::system::error_code const &  ec,
std::string const &  errMsg,
std::shared_ptr< parser parser 
)
protected

Definition at line 311 of file HTTPDownloader.cpp.

◆ do_session()

void ripple::HTTPDownloader::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 
)
private

Definition at line 87 of file HTTPDownloader.cpp.

◆ getParser()

virtual std::shared_ptr<parser> ripple::HTTPDownloader::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::HTTPDownloader::checkPath ( boost::filesystem::path const &  dstPath)
privatepure virtual

Implemented in ripple::DatabaseDownloader.

◆ closeBody()

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

Implemented in ripple::DatabaseDownloader.

◆ size()

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

Implemented in ripple::DatabaseDownloader.

Member Data Documentation

◆ j_

const beast::Journal ripple::HTTPDownloader::j_
protected

Definition at line 80 of file HTTPDownloader.h.

◆ config_

Config const& ripple::HTTPDownloader::config_
private

Definition at line 90 of file HTTPDownloader.h.

◆ strand_

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

Definition at line 91 of file HTTPDownloader.h.

◆ stream_

std::unique_ptr<HTTPStream> ripple::HTTPDownloader::stream_
private

Definition at line 92 of file HTTPDownloader.h.

◆ read_buf_

boost::beast::flat_buffer ripple::HTTPDownloader::read_buf_
private

Definition at line 93 of file HTTPDownloader.h.

◆ stop_

std::atomic<bool> ripple::HTTPDownloader::stop_
private

Definition at line 94 of file HTTPDownloader.h.

◆ m_

std::mutex ripple::HTTPDownloader::m_
mutableprivate

Definition at line 97 of file HTTPDownloader.h.

◆ sessionActive_

bool ripple::HTTPDownloader::sessionActive_
private

Definition at line 98 of file HTTPDownloader.h.

◆ c_

std::condition_variable ripple::HTTPDownloader::c_
private

Definition at line 99 of file HTTPDownloader.h.