AutoIt
AutoIt
Example: Http.QuickGet method
Demonstrates theQuickGet method.
Chilkat AutoIt Downloads
Local $bSuccess = False
; This example requires the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.
$oHttp = ObjCreate("Chilkat.Http")
$oHttp.KeepResponseBody = True
; This URL is valid and can be tested...
Local $oZipBytes
$oZipBytes = $oHttp.QuickGet("https://chilkatdownload.com/example_data/hamlet.zip")
If ($oHttp.LastMethodSuccess = False) Then
ConsoleWrite($oHttp.LastErrorText & @CRLF)
Exit
EndIf
If ($oHttp.LastStatus <> 200) Then
ConsoleWrite("Response status code: " & $oHttp.LastStatus & @CRLF)
ConsoleWrite($oHttp.LastResponseBody & @CRLF)
Exit
EndIf
$oZip = ObjCreate("Chilkat.Zip")
; Open the zip from the bytes contained in bd.
$bSuccess = $oZip.OpenFromMemory($oZipBytes)
If ($bSuccess = False) Then
ConsoleWrite($oZip.LastErrorText & @CRLF)
Exit
EndIf
; Get the entry for the file we want..
$oEntry = ObjCreate("Chilkat.ZipEntry")
$bSuccess = $oZip.EntryOf("hamlet.xml",$oEntry)
If ($bSuccess = False) Then
ConsoleWrite($oZip.LastErrorText & @CRLF)
Exit
EndIf
; Convert all line endings to CRLF (if needed)
Local $iLineEndingBehavior = 2
Local $sXmlStr = $oEntry.UnzipToString($iLineEndingBehavior,"utf-8")
If ($oEntry.LastMethodSuccess = False) Then
ConsoleWrite($oEntry.LastErrorText & @CRLF)
Exit
EndIf
; The XML in this case is about 274K, so let's just examine the last 20 lines...
$oSb = ObjCreate("Chilkat.StringBuilder")
$oSb.Append($sXmlStr)
ConsoleWrite($oSb.LastNLines(20,True) & @CRLF)