crawlserv++  [under development]
Application for crawling and analyzing textual content of websites.
crawlservpp::Network::Downloader Class Reference

Downloader using the libcurl library to download a URL in an extra thread. More...

#include <Downloader.hpp>

Construction and Destruction

 Downloader (const std::string &url, const std::string &proxy=std::string{})
 Constructor starting to download a URL using a specific proxy server. More...
 
 ~Downloader ()
 Destructor. More...
 

Getters

bool isRunning () const noexcept
 Returns whether the download is still in progress. More...
 
std::string getContent () const
 Returns the downloaded content, if successfully downloaded. More...
 
std::string getError () const
 Returns the download error, if one occured. More...
 

Detailed Description

Downloader using the libcurl library to download a URL in an extra thread.

Constructor & Destructor Documentation

◆ Downloader()

crawlservpp::Network::Downloader::Downloader ( const std::string &  url,
const std::string &  proxy = std::string{} 
)
inline

Constructor starting to download a URL using a specific proxy server.

Parameters
urlThe URL to download.
proxyThe proxy server used for the download. No specific proxy server is used if the string is empty.

◆ ~Downloader()

crawlservpp::Network::Downloader::~Downloader ( )
inline

Destructor.

Joins the download with the main thread.

Member Function Documentation

◆ getContent()

std::string crawlservpp::Network::Downloader::getContent ( ) const
inline

Returns the downloaded content, if successfully downloaded.

Note
This function is thread-safe.
Returns
The content of the downloaded file or an empty string, if the download is still in progress or has failed.
See also
getError

◆ getError()

std::string crawlservpp::Network::Downloader::getError ( ) const
inline

Returns the download error, if one occured.

Note
This function is thread-safe.
Returns
The error, if one occured, or an empty string if the download is still in progress or was successful.
See also
getContent

References crawlservpp::Helper::Container::append(), crawlservpp::Helper::Container::bytes(), crawlservpp::Wrapper::Curl::get(), and crawlservpp::Wrapper::Curl::valid().

◆ isRunning()

bool crawlservpp::Network::Downloader::isRunning ( ) const
inlinenoexcept

Returns whether the download is still in progress.

Note
This function is thread-safe.
Returns
True, if the download is still in progress. False otherwise.

The documentation for this class was generated from the following file: