Sample code for 30+ languages & platforms
AutoIt

Disconnect from a REST Server

See more REST Examples

Demonstrates Rest.Disconnect, which closes the current HTTP connection. The argument is the maximum number of milliseconds to wait for the close to complete.

Background. Connections are normally kept alive for reuse. Disconnect is used when an application wants to explicitly release the connection rather than relying on keep-alive or object destruction.

Chilkat AutoIt Downloads

AutoIt
Local $bSuccess = False

$oRest = ObjCreate("Chilkat.Rest")

;  Connect to the REST server.  The 3rd argument enables TLS (use True for HTTPS on port 443),
;  and the 4th enables automatic reconnection if the connection is dropped between requests.
Local $bTls = True
Local $bAutoReconnect = True
$bSuccess = $oRest.Connect("example.com",443,$bTls,$bAutoReconnect)
If ($bSuccess = False) Then
    ConsoleWrite($oRest.LastErrorText & @CRLF)
    Exit
EndIf

Local $sResponseText = $oRest.FullRequestNoBody("GET","/api/status")
If ($oRest.LastMethodSuccess = False) Then
    ConsoleWrite($oRest.LastErrorText & @CRLF)
    Exit
EndIf

ConsoleWrite($sResponseText & @CRLF)

;  Close the connection.  The argument is the maximum number of milliseconds to wait for the
;  close to complete.
Local $bDisconnected = $oRest.Disconnect(200)
If ($bDisconnected <> True) Then
    ConsoleWrite("The disconnect did not complete within the wait time." & @CRLF)
EndIf

ConsoleWrite("Done." & @CRLF)