Sample code for 30+ languages & platforms
Xbase++

Example: Http.ResumeDownload method

Demonstrates the ResumeDownload method.

Chilkat Xbase++ Downloads

Xbase++
LOCAL nSuccess
LOCAL oHttp
LOCAL cLocalFilePath
LOCAL nStatusCode
LOCAL oFac

nSuccess := 0

oHttp := CreateObject("Chilkat.Http")
oHttp:KeepResponseBody := 1

//  To demonstrate resuming a download, we've created a file on the chilkatsoft.com
//  web server that contains the first 82,379 bytes of the full  279,658 bytes of the hamlet.xml file.

//  We'll first download the partial file, and pretend it was a previous incomplete attempt to download the entire file.
cLocalFilePath := "c:/temp/qa_output/hamlet.xml"
nSuccess := oHttp:Download("https://www.chilkatsoft.com/testData/hamlet_partial.xml", cLocalFilePath)
IF (nSuccess == 0)
    ? oHttp:LastErrorText
    oHttp:destroy()
    RETURN
ENDIF

//  Download the remainder of hamlet.xml.
nSuccess := oHttp:ResumeDownload("https://www.chilkatsoft.com/testData/hamlet.xml", cLocalFilePath)
nStatusCode := oHttp:LastStatus
IF (nSuccess == 0)
    IF (nStatusCode == 0)
        //  Unable to either send the request or get the response.
        ? oHttp:LastErrorText
    ELSE
        //  We got a response, but the status code was not in the 200s
        ? "Response status code: " + Str(nStatusCode)
        //  Examine the response body.
        ? "Response body:"
        ? oHttp:LastResponseBody
    ENDIF

    ? "Download failed."

ELSE
    ? "Download success, response status = " + Str(nStatusCode)
ENDIF

//  The hamlet.xml file should be 279,658 bytes
oFac := CreateObject("Chilkat.FileAccess")
? "size of hamlet.xml: " + Str(oFac:FileSize(cLocalFilePath))

? "Success."

oHttp:destroy()
oFac:destroy()