(AutoIt) Example: Http.DownloadSb method
Demonstrates the DownloadSb method.
Local $bSuccess = False
$oHttp = ObjCreate("Chilkat.Http")
$oHttp.KeepResponseBody = True
$oSb = ObjCreate("Chilkat.StringBuilder")
$bSuccess = $oHttp.DownloadSb("https://chilkatsoft.com/testData/helloWorld.txt","utf-8",$oSb)
Local $iStatusCode = $oHttp.LastStatus
If ($bSuccess = False) Then
If ($iStatusCode = 0) Then
; Unable to either send the request or get the response.
ConsoleWrite($oHttp.LastErrorText & @CRLF)
Else
; We got a response, but the status code was not in the 200s
ConsoleWrite("Response status code: " & $iStatusCode & @CRLF)
; Examine the response body.
ConsoleWrite("Response body:" & @CRLF)
ConsoleWrite($oHttp.LastResponseBody & @CRLF)
EndIf
ConsoleWrite("Download failed." & @CRLF)
Else
ConsoleWrite("Download success, response status = " & $iStatusCode & @CRLF)
ConsoleWrite($oSb.GetAsString() & @CRLF)
EndIf
|