Sample code for 30+ languages & platforms
Lianja

Example: Http.ResumeDownloadBd method

Demonstrates the ResumeDownloadBd method.

Chilkat Lianja Downloads

Lianja
llSuccess = .F.

loHttp = createobject("CkHttp")
loHttp.KeepResponseBody = .T.

// 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.
loBd = createobject("CkBinData")
llSuccess = loHttp.DownloadBd("https://www.chilkatsoft.com/testData/hamlet_partial.xml",loBd)
if (llSuccess = .F.) then
    ? loHttp.LastErrorText
    release loHttp
    release loBd
    return
endif

// Download the remainder of hamlet.xml.
llSuccess = loHttp.ResumeDownloadBd("https://www.chilkatsoft.com/testData/hamlet.xml",loBd)
lnStatusCode = loHttp.LastStatus
if (llSuccess = .F.) then
    if (lnStatusCode = 0) then
        // Unable to either send the request or get the response.
        ? loHttp.LastErrorText
    else
        // We got a response, but the status code was not in the 200s
        ? "Response status code: " + str(lnStatusCode)
        // Examine the response body.
        ? "Response body:"
        ? loHttp.LastResponseBody
    endif

    ? "Download failed."

else
    ? "Download success, response status = " + str(lnStatusCode)
endif

// The hamlet.xml file should be 279,658 bytes
? "size of hamlet.xml: " + str(loBd.NumBytes)

? "Success."


release loHttp
release loBd