util_httpopen method url { rqset " " } { timeout "30" } { http_referer " " }What it does:
Like ns_httpopen but works for POST as well; called by util_httppostDefined in: /web/philip/packages/acs-core/utilities-procs.tcl
Source code:
if ![string match http://* $url] {
return -code error "Invalid url \"$url\": _httpopen only supports HTTP"
}
set url [split $url /]
set hp [split [lindex $url 2] :]
set host [lindex $hp 0]
set port [lindex $hp 1]
if [string match $port ""] {set port 80}
set uri /[join [lrange $url 3 end] /]
set fds [ns_sockopen -nonblock $host $port]
set rfd [lindex $fds 0]
set wfd [lindex $fds 1]
if [catch {
_ns_http_puts $timeout $wfd "$method $uri HTTP/1.0\r"
if {$rqset != ""} {
for {set i 0} {$i < [ns_set size $rqset]} {incr i} {
_ns_http_puts $timeout $wfd "[ns_set key $rqset $i]: [ns_set value $rqset $i]\r"
}
} else {
_ns_http_puts $timeout $wfd "Accept: */*\r"
_ns_http_puts $timeout $wfd "User-Agent: Mozilla/1.01 \[en\] (Win95; I)\r"
_ns_http_puts $timeout $wfd "Referer: $http_referer \r"
}
} errMsg] {
global errorInfo
#close $wfd
#close $rfd
if [info exists rpset] {ns_set free $rpset}
return -1
}
return [list $rfd $wfd ""]