Visual FoxPro
Visual FoxPro
Example: Http.ResumeDownloadBd method
Demonstrates theResumeDownloadBd method.
Chilkat Visual FoxPro Downloads
LOCAL lnSuccess
LOCAL loHttp
LOCAL loBd
LOCAL lnStatusCode
lnSuccess = 0
loHttp = CreateObject('Chilkat.Http')
loHttp.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.
loBd = CreateObject('Chilkat.BinData')
lnSuccess = loHttp.DownloadBd("https://www.chilkatsoft.com/testData/hamlet_partial.xml",loBd)
IF (lnSuccess = 0) THEN
? loHttp.LastErrorText
RELEASE loHttp
RELEASE loBd
CANCEL
ENDIF
* Download the remainder of hamlet.xml.
lnSuccess = loHttp.ResumeDownloadBd("https://www.chilkatsoft.com/testData/hamlet.xml",loBd)
lnStatusCode = loHttp.LastStatus
IF (lnSuccess = 0) 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