class System::Network::Download

An easy to use class for downloading data from HTTP internet sites.

Constructors

Download (const string)Constructs a new download instance from a given URL.
Download (const string, const string)Constructs a new download instance from a given URL and referrer string.
Download (const string, const string, const string)Constructs a new download instance specifying the HTTP method to use.

Methods

Abort ()Stops a download that is currently in progress.
string GetContent ()Returns the entire content of the downloaded data as a string.
string GetHeaderField (string)Returns the value of the specified header field.
int Receive ()Call this repeatedly to receive data.
SaveContent (const string)Saves the entire content of the downloaded data to a file.

Properties

int ContentLength ()Returns the length of the data, if specified in the mime-header transmitted by the web server.
string ContentType ()Returns the content type as specified in the mime-header transmitted by the web server.
int DownloadedLength ()Returns the actual length of the downloaded data.
string InitialUrl ()Returns the initial URL specified when the download was created.
string MimeHeader ()Returns the mime-header as transmitted by the web server.
int QueueIndex ()Returns the queue index for this download.
string Referrer ()Returns the referrer string specified when the download was created.
int ResultCode ()In case of an HTTP error, returns the error code.
int Status ()Returns one of the following: Download::Continue, Download::Complete, Download::Error, Download::TimeOut.
string TargetUrl ()Returns the target URL.

Type Declaration

native class System::Network::Download
{
    ["An easy to use class for downloading data from HTTP internet sites."]
    method Download (const string url); ["Constructs a new download instance from a given URL. This will perform a HTTP/1.1 GET query."]
    method Download (const string url, const string ref); ["Constructs a new download instance from a given URL and referrer string. This will perform a HTTP/1.1 GET query."]
    method Download (const string _method, const string url, const string params); ["Constructs a new download instance specifying the HTTP method to use. The method string is CASE SENSITIVE and can only be 'POST' or 'GET'. If the method is 'POST', the string 'param' can specify additional url-encoded parameters for the POST query. If the method is 'GET' the string 'param' can specify an additional referrer string for the GET query."]
    method int Receive (); ["Call this repeatedly to receive data. This function will return Download::Continue if only a portion of the data has been received. Keep calling this method until it returns Download::Complete, Download::Error or Download::TimeOut. If Download::Error is returned, the actual HTTP error code can be obtained by Download::ResultCode."]
    method string GetContent (); ["Returns the entire content of the downloaded data as a string."]
    method SaveContent (const string filename); ["Saves the entire content of the downloaded data to a file."]
    method Abort (); ["Stops a download that is currently in progress."]
    method string GetHeaderField (string name); ["Returns the value of the specified header field. If the specified field does not exist, returns an empty string."]
    accessor int Status (); ["Returns one of the following: Download::Continue, Download::Complete, Download::Error, Download::TimeOut."]
    accessor int ResultCode (); ["In case of an HTTP error, returns the error code."]
    accessor int ContentLength (); ["Returns the length of the data, if specified in the mime-header transmitted by the web server. If not specified, returns 0."]
    accessor int DownloadedLength (); ["Returns the actual length of the downloaded data. This value can be different from Download::ContentLength."]
    accessor string MimeHeader (); ["Returns the mime-header as transmitted by the web server."]
    accessor string TargetUrl (); ["Returns the target URL. If the web server has redirected the url, this can differ from the Download::InitialUrl."]
    accessor string ContentType (); ["Returns the content type as specified in the mime-header transmitted by the web server."]
    accessor string InitialUrl (); ["Returns the initial URL specified when the download was created."]
    accessor string Referrer (); ["Returns the referrer string specified when the download was created."]
    accessor int QueueIndex (); ["Returns the queue index for this download. The queue index is a unique number assigned by the DownloadManager to every download when added. It starts at zero and continuously increases by one for each download."]
    const int Error = -2;
    const int TimeOut = -1;
    const int Continue = 0;
    const int HeaderComplete = 1;
    const int Complete = 2;
    const int Failed = 3;
    const int Aborted = 4;
}

Reference

method Download (const string url)

Constructs a new download instance from a given URL.

This will perform a HTTP/1.1 GET query.


method Download (const string url, const string ref)

Constructs a new download instance from a given URL and referrer string.

This will perform a HTTP/1.1 GET query.


method Download (const string _method, const string url, const string params)

Constructs a new download instance specifying the HTTP method to use.

The method string is CASE SENSITIVE and can only be 'POST' or 'GET'. If the method is 'POST', the string 'param' can specify additional url-encoded parameters for the POST query. If the method is 'GET' the string 'param' can specify an additional referrer string for the GET query.


method Abort ()

Stops a download that is currently in progress.


method string GetContent ()

Returns the entire content of the downloaded data as a string.


method string GetHeaderField (string name)

Returns the value of the specified header field.

If the specified field does not exist, returns an empty string.


method int Receive ()

Call this repeatedly to receive data.

This function will return Download::Continue if only a portion of the data has been received. Keep calling this method until it returns Download::Complete, Download::Error or Download::TimeOut. If Download::Error is returned, the actual HTTP error code can be obtained by Download::ResultCode.


method SaveContent (const string filename)

Saves the entire content of the downloaded data to a file.


accessor int ContentLength ()

Returns the length of the data, if specified in the mime-header transmitted by the web server.

If not specified, returns 0.


accessor string ContentType ()

Returns the content type as specified in the mime-header transmitted by the web server.


accessor int DownloadedLength ()

Returns the actual length of the downloaded data.

This value can be different from Download::ContentLength.


accessor string InitialUrl ()

Returns the initial URL specified when the download was created.


accessor string MimeHeader ()

Returns the mime-header as transmitted by the web server.


accessor int QueueIndex ()

Returns the queue index for this download.

The queue index is a unique number assigned by the DownloadManager to every download when added. It starts at zero and continuously increases by one for each download.


accessor string Referrer ()

Returns the referrer string specified when the download was created.


accessor int ResultCode ()

In case of an HTTP error, returns the error code.


accessor int Status ()

Returns one of the following: Download::Continue, Download::Complete, Download::Error, Download::TimeOut.


accessor string TargetUrl ()

Returns the target URL.

If the web server has redirected the url, this can differ from the Download::InitialUrl.