VBScript
VBScript
Transition from Http.GetHead to Http.HttpNoBody
Provides instructions for replacing deprecated GetHead method calls with HttpNoBody.Chilkat VBScript Downloads
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 http = CreateObject("Chilkat.Http")
url = "https://www.example.com/"
' ------------------------------------------------------------------------
' The GetHead method is deprecated:
' resp1 is a Chilkat.HttpResponse
Set resp1 = http.GetHead(url)
If (http.LastMethodSuccess = 0) Then
outFile.WriteLine(http.LastErrorText)
WScript.Quit
End If
outFile.WriteLine(resp1.StatusCode)
' ------------------------------------------------------------------------
' Do the equivalent using HttpNoBody.
' Your application creates a new, empty response object which is passed
' in the last argument and filled with the HTTP response upon success.
set resp2 = CreateObject("Chilkat.HttpResponse")
success = http.HttpNoBody("HEAD",url,resp2)
If (success = 0) Then
outFile.WriteLine(http.LastErrorText)
WScript.Quit
End If
outFile.WriteLine(resp2.StatusCode)
outFile.Close