util_httpget url { headers " " } { timeout "30" } { depth "0" }What it does:
Just like ns_httpget, but first optional argument is an ns_set of headers to send during the fetch.Defined in: /web/philip/packages/acs-core/utilities-procs.tcl
Source code:
if {[incr depth] > 10} {
return -code error "util_httpget: Recursive redirection: $url"
}
set http [ns_httpopen GET $url $headers $timeout]
set rfd [lindex $http 0]
close [lindex $http 1]
set headers [lindex $http 2]
set response [ns_set name $headers]
set status [lindex $response 1]
if {$status == 302} {
set location [ns_set iget $headers location]
if {$location != ""} {
ns_set free $headers
close $rfd
return [ns_httpget $location $timeout $depth]
}
}
set length [ns_set iget $headers content-length]
if [string match "" $length] {set length -1}
set err [catch {
while 1 {
set buf [_http_read $timeout $rfd $length]
append page $buf
if [string match "" $buf] break
if {$length > 0} {
incr length -[string length $buf]
if {$length <= 0} break
}
}
} errMsg]
ns_set free $headers
close $rfd
if $err {
global errorInfo
return -code error -errorinfo $errorInfo $errMsg
}
return $page