(Tcl) Example: Http.DownloadSb method
Demonstrates the DownloadSb method.
load ./chilkat.dll
set success 0
set http [new_CkHttp]
CkHttp_put_KeepResponseBody $http 1
set sb [new_CkStringBuilder]
set success [CkHttp_DownloadSb $http "https://chilkatsoft.com/testData/helloWorld.txt" "utf-8" $sb]
set statusCode [CkHttp_get_LastStatus $http]
if {$success == 0} then {
if {$statusCode == 0} then {
# Unable to either send the request or get the response.
puts [CkHttp_lastErrorText $http]
} else {
# We got a response, but the status code was not in the 200s
puts "Response status code: $statusCode"
# Examine the response body.
puts "Response body:"
puts [CkHttp_lastResponseBody $http]
}
puts "Download failed."
} else {
puts "Download success, response status = $statusCode"
puts [CkStringBuilder_getAsString $sb]
}
delete_CkHttp $http
delete_CkStringBuilder $sb
|