![]() |
Chilkat HOME Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi DLL Go Java Node.js Objective-C PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(PureBasic) Example: Http.ResumeDownload methodDemonstrates the
IncludeFile "CkFileAccess.pb" IncludeFile "CkHttp.pb" Procedure ChilkatExample() success.i = 0 http.i = CkHttp::ckCreate() If http.i = 0 Debug "Failed to create object." ProcedureReturn EndIf CkHttp::setCkKeepResponseBody(http, 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. localFilePath.s = "c:/temp/qa_output/hamlet.xml" success = CkHttp::ckDownload(http,"https://www.chilkatsoft.com/testData/hamlet_partial.xml",localFilePath) If success = 0 Debug CkHttp::ckLastErrorText(http) CkHttp::ckDispose(http) ProcedureReturn EndIf ; Download the remainder of hamlet.xml. success = CkHttp::ckResumeDownload(http,"https://www.chilkatsoft.com/testData/hamlet.xml",localFilePath) statusCode.i = CkHttp::ckLastStatus(http) If success = 0 If statusCode = 0 ; Unable to either send the request or get the response. Debug CkHttp::ckLastErrorText(http) Else ; We got a response, but the status code was not in the 200s Debug "Response status code: " + Str(statusCode) ; Examine the response body. Debug "Response body:" Debug CkHttp::ckLastResponseBody(http) EndIf Debug "Download failed." Else Debug "Download success, response status = " + Str(statusCode) EndIf ; The hamlet.xml file should be 279,658 bytes fac.i = CkFileAccess::ckCreate() If fac.i = 0 Debug "Failed to create object." ProcedureReturn EndIf Debug "size of hamlet.xml: " + Str(CkFileAccess::ckFileSize(fac,localFilePath)) Debug "Success." CkHttp::ckDispose(http) CkFileAccess::ckDispose(fac) ProcedureReturn EndProcedure |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.