Xbase++
Xbase++
Example: Http.DownloadSb method
See more HTTP Examples
Demonstrates theDownloadSb method.
Chilkat Xbase++ Downloads
LOCAL nSuccess
LOCAL oHttp
LOCAL oSb
LOCAL nStatusCode
nSuccess := 0
oHttp := CreateObject("Chilkat.Http")
oHttp:KeepResponseBody := 1
oSb := CreateObject("Chilkat.StringBuilder")
nSuccess := oHttp:DownloadSb("https://chilkatsoft.com/testData/helloWorld.txt", "utf-8", oSb)
nStatusCode := oHttp:LastStatus
IF (nSuccess == 0)
IF (nStatusCode == 0)
// Unable to either send the request or get the response.
? oHttp:LastErrorText
ELSE
// We got a response, but the status code was not in the 200s
? "Response status code: " + Str(nStatusCode)
// Examine the response body.
? "Response body:"
? oHttp:LastResponseBody
ENDIF
? "Download failed."
ELSE
? "Download success, response status = " + Str(nStatusCode)
? oSb:GetAsString()
ENDIF
oHttp:destroy()
oSb:destroy()