![]() |
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
(Visual FoxPro) Example: Http.DownloadAppend methodDemonstrates the DownloadAppend method.
LOCAL lnSuccess LOCAL lcTargetPath LOCAL loHttp LOCAL lnStatusCode LOCAL loSb LOCAL loFac lnSuccess = 0 lnSuccess = 0 lcTargetPath = "c:/temp/qa_output/download.txt" loHttp = CreateObject('Chilkat.Http') loHttp.KeepResponseBody = 1 * Assume the target file in the local filesystem does not yet exist. lnSuccess = loHttp.DownloadAppend("https://chilkatsoft.com/testData/helloWorld.txt",lcTargetPath) lnStatusCode = loHttp.LastStatus IF (lnStatusCode = 0) THEN * Unable to either send the request or get the response. ? loHttp.LastErrorText RELEASE loHttp CANCEL ENDIF * Should be 200. ? "Response status code: " + STR(lnStatusCode) * Examine the contents of the file. loSb = CreateObject('Chilkat.StringBuilder') loSb.LoadFile(lcTargetPath,"utf-8") ? loSb.GetAsString() * Output: * Response status code: 200 * Hello World! * Download another text file and append to the target file. lnSuccess = loHttp.DownloadAppend("https://chilkatsoft.com/testData/this_is_a_test.txt",lcTargetPath) lnStatusCode = loHttp.LastStatus IF (lnStatusCode = 0) THEN * Unable to either send the request or get the response. ? loHttp.LastErrorText RELEASE loHttp RELEASE loSb CANCEL ENDIF * Should be 200. ? "Response status code: " + STR(lnStatusCode) * Examine the contents of the file. loSb.LoadFile(lcTargetPath,"utf-8") ? loSb.GetAsString() * Output: * Response status code: 200 * Hello World!This is a Test. * Delete the local target file. loFac = CreateObject('Chilkat.FileAccess') loFac.FileDelete(lcTargetPath) * Try to download a file that does not exist: lnSuccess = loHttp.DownloadAppend("https://chilkatsoft.com/testData/does_not_exist.txt",lcTargetPath) lnStatusCode = loHttp.LastStatus IF (lnStatusCode = 0) THEN * Unable to either send the request or get the response. ? loHttp.LastErrorText ELSE * We got a response, and we already know it wasn't a 200 success response. * It should be a 404 not found. ? "Response status code: " + STR(lnStatusCode) * Examine the response body. ? "Response body:" ? loHttp.LastResponseBody ENDIF RELEASE loHttp RELEASE loSb RELEASE loFac |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.