Lianja
Lianja
Example: Http.ResumeDownload method
Demonstrates theResumeDownload method.
Chilkat Lianja Downloads
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.
lcLocalFilePath = "c:/temp/qa_output/hamlet.xml"
llSuccess = loHttp.Download("https://www.chilkatsoft.com/testData/hamlet_partial.xml",lcLocalFilePath)
if (llSuccess = .F.) then
? loHttp.LastErrorText
release loHttp
return
endif
// Download the remainder of hamlet.xml.
llSuccess = loHttp.ResumeDownload("https://www.chilkatsoft.com/testData/hamlet.xml",lcLocalFilePath)
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
loFac = createobject("CkFileAccess")
? "size of hamlet.xml: " + str(loFac.FileSize(lcLocalFilePath))
? "Success."
release loHttp
release loFac