Xbase++
Xbase++
Example: Http.ResumeDownloadBd method
Demonstrates theResumeDownloadBd method.
Chilkat Xbase++ Downloads
LOCAL nSuccess
LOCAL oHttp
LOCAL oBd
LOCAL nStatusCode
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.
oBd := CreateObject("Chilkat.BinData")
nSuccess := oHttp:DownloadBd("https://www.chilkatsoft.com/testData/hamlet_partial.xml", oBd)
IF (nSuccess == 0)
? oHttp:LastErrorText
oHttp:destroy()
oBd:destroy()
RETURN
ENDIF
// Download the remainder of hamlet.xml.
nSuccess := oHttp:ResumeDownloadBd("https://www.chilkatsoft.com/testData/hamlet.xml", oBd)
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
? "size of hamlet.xml: " + Str(oBd:NumBytes)
? "Success."
oHttp:destroy()
oBd:destroy()