(Tcl) Add Custom Header to HTTP GET
Demonstrates how to add a custom HTTP request header to an HTTP GET. This is not a request parameter, but is a header added to the MIME header of the HTTP request.
load ./chilkat.dll
# All Chilkat classes can be unlocked at once at the beginning of a program
# by calling UnlockBundle. It requires a Bundle unlock code.
set chilkatGlob [new_CkGlobal]
set success [CkGlobal_UnlockBundle $chilkatGlob "Anything for 30-day trial."]
if {$success != 1} then {
puts [CkGlobal_lastErrorText $chilkatGlob]
delete_CkGlobal $chilkatGlob
exit
}
set http [new_CkHttp]
# Add a custom header. The MIME field name is "X-CSRF-Token", and the
# header field value is "Fetch".
CkHttp_SetRequestHeader $http "X-CSRF-Token" "Fetch"
# Send the HTTP GET and return the content in a string.
set html [CkHttp_quickGetStr $http "http://www.galapagos.org/"]
puts "$html"
delete_CkGlobal $chilkatGlob
delete_CkHttp $http
|