(PowerShell) Transition from Http.GetHead to Http.HttpNoBody
Provides instructions for replacing deprecated GetHead method calls with HttpNoBody. Note: This example requires Chilkat v11.0.0 or greater.
Add-Type -Path "C:\chilkat\ChilkatDotNet47-x64\ChilkatDotNet47.dll"
$http = New-Object Chilkat.Http
$url = "https://www.example.com/"
# ------------------------------------------------------------------------
# The GetHead method is deprecated:
$resp1 = $http.GetHead($url)
if ($http.LastMethodSuccess -eq $false) {
$($http.LastErrorText)
exit
}
$($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.
$resp2 = New-Object Chilkat.HttpResponse
$success = $http.HttpNoBody("HEAD",$url,$resp2)
if ($success -eq $false) {
$($http.LastErrorText)
exit
}
$($resp2.StatusCode)
|