Downloader. More...
#include <rdownload.h>
Public Member Functions | |
RDownload (void) | |
void | Download (const RURI &uri) |
RString | GetMIMEType (void) |
virtual | ~RDownload (void) |
Private Member Functions | |
virtual bool | IsValidContent (const R::RString &MIME) |
virtual bool | StartDownload (void) |
virtual size_t | GetData (void *buffer, size_t size, size_t nmemb) |
virtual void | EndDownload (void) |
Static Private Member Functions | |
static size_t | WriteTmpFile (void *buffer, size_t size, size_t nmemb, void *param) |
static size_t | TreatHeader (void *buffer, size_t size, size_t nmemb, void *param) |
Private Attributes | |
void * | Lib |
bool | ValidContent |
RString | MIME |
bool | First |
RURI | URI |
Static Private Attributes | |
static bool | MustInitCURL |
Detailed Description
Downloader.
The RDownload class provides a session that will download content retrieved from URLs. To store the content in a file, use the RDownloadFile class.
This class is a encapsulation of libCURL.
Constructor & Destructor Documentation
RDownload | ( | void | ) |
Construct the downloader.
|
virtual |
Destruct the downloader.
Member Function Documentation
|
staticprivate |
Parameter function given to CURLOPT_WRITEFUNCTION and called by CURL when data are downloaded.
The total size downloaded is given by size multiplied with nmemb.
- Parameters
-
buffer Pointer to the delivered data size Size of an element downloaded. nmemb Number of elements downloaded.
|
staticprivate |
Parameter function given to CURLOPT_HEADERFUNCTION and called by CURL when a part of the header is downloaded.
The total size downloaded is given by size multiplied with nmemb.
- Parameters
-
buffer Pointer to the delivered data size Size of an element downloaded. nmemb Number of elements downloaded.
|
privatevirtual |
If the protocol is HTTP and the server returns a content type for the downloaded file, this function is called to verify if the file should be really downloaded.
- Parameters
-
MIME MIME type send by the server.
- Returns
- true if the file should be downloaded (default).
|
privatevirtual |
Method called when the download of file starts.
- Returns
- true if the file should really be downloaded (default).
|
privatevirtual |
Call each time a given amount of data is downloaded. By default, it does nothing.
- Parameters
-
buffer Pointer to the delivered data size Size of an element downloaded. nmemb Number of elements downloaded.
- Returns
- the number of bytes actually taken care of. If it differs from the number of bytes downloaded, the download is stopped.
Reimplemented in RDownloadFile.
|
privatevirtual |
Method called when the dowload finishes. By default, it does nothing
void Download | ( | const RURI & | uri | ) |
Download a document given by an URI.
- Parameters
-
uri URI of the document.
RString GetMIMEType | ( | void | ) |
Get the current MIME type.
Field Documentation
|
private |
Pointer to an instance of the library.
|
private |
Valid Content?
|
private |
Current MIME Type;
|
private |
Is it the first bloc of data downloaded?
|
private |
URI to download.
|
staticprivate |
Was CURL Initialize ?