(Visual FoxPro) Example: Http.DownloadSb method
Demonstrates the DownloadSb method.
LOCAL lnSuccess
LOCAL loHttp
LOCAL loSb
LOCAL lnStatusCode
lnSuccess = 0
loHttp = CreateObject('Chilkat.Http')
loHttp.KeepResponseBody = 1
loSb = CreateObject('Chilkat.StringBuilder')
lnSuccess = loHttp.DownloadSb("https://chilkatsoft.com/testData/helloWorld.txt","utf-8",loSb)
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)
? loSb.GetAsString()
ENDIF
RELEASE loHttp
RELEASE loSb
|