Visual FoxPro
Visual FoxPro
Example: Http.ResumeDownload method
Demonstrates theResumeDownload method.
Chilkat Visual FoxPro Downloads
LOCAL lnSuccess
LOCAL loHttp
LOCAL lcLocalFilePath
LOCAL lnStatusCode
LOCAL loFac
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.
lcLocalFilePath = "c:/temp/qa_output/hamlet.xml"
lnSuccess = loHttp.Download("https://www.chilkatsoft.com/testData/hamlet_partial.xml",lcLocalFilePath)
IF (lnSuccess = 0) THEN
? loHttp.LastErrorText
RELEASE loHttp
CANCEL
ENDIF
* Download the remainder of hamlet.xml.
lnSuccess = loHttp.ResumeDownload("https://www.chilkatsoft.com/testData/hamlet.xml",lcLocalFilePath)
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
loFac = CreateObject('Chilkat.FileAccess')
? "size of hamlet.xml: " + STR(loFac.FileSize(lcLocalFilePath))
? "Success."
RELEASE loHttp
RELEASE loFac