Sample code for 30+ languages & platforms
VBScript

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 VBScript Downloads

VBScript
Dim fso, outFile
Set fso = CreateObject("Scripting.FileSystemObject")
'Create a Unicode (utf-16) output text file.
Set outFile = fso.CreateTextFile("output.txt", True, True)

success = 0

set rest = CreateObject("Chilkat.Rest")

'  Connect to the REST server.  The 3rd argument enables TLS (use 1 for HTTPS on port 443),
'  and the 4th enables automatic reconnection if the connection is dropped between requests.
bTls = 1
bAutoReconnect = 1
success = rest.Connect("example.com",443,bTls,bAutoReconnect)
If (success = 0) Then
    outFile.WriteLine(rest.LastErrorText)
    WScript.Quit
End If

responseText = rest.FullRequestNoBody("GET","/api/status")
If (rest.LastMethodSuccess = 0) Then
    outFile.WriteLine(rest.LastErrorText)
    WScript.Quit
End If

outFile.WriteLine(responseText)

'  Close the connection.  The argument is the maximum number of milliseconds to wait for the
'  close to complete.
bDisconnected = rest.Disconnect(200)
If (bDisconnected <> 1) Then
    outFile.WriteLine("The disconnect did not complete within the wait time.")
End If

outFile.WriteLine("Done.")

outFile.Close