(Tcl) 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.
load ./chilkat.dll
set http [new_CkHttp]
set url "https://www.example.com/"
# ------------------------------------------------------------------------
# The GetHead method is deprecated:
# resp1 is a CkHttpResponse
set resp1 [CkHttp_GetHead $http $url]
if {[CkHttp_get_LastMethodSuccess $http] == 0} then {
puts [CkHttp_lastErrorText $http]
delete_CkHttp $http
exit
}
puts [CkHttpResponse_get_StatusCode $resp1]
delete_CkHttpResponse $resp1
# ------------------------------------------------------------------------
# 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 [new_CkHttpResponse]
set success [CkHttp_HttpNoBody $http "HEAD" $url $resp2]
if {$success == 0} then {
puts [CkHttp_lastErrorText $http]
delete_CkHttp $http
delete_CkHttpResponse $resp2
exit
}
puts [CkHttpResponse_get_StatusCode $resp2]
delete_CkHttp $http
delete_CkHttpResponse $resp2
|