The cookie spec told me that I needed to send a "Cookie:" header with all the cookies expected for the session.
The hacked-up version of http.tcl (cf ~aolserver/modules/tcl/http.tcl) from Holly Jerry was able to handle cookies in an rqset (ns_set). I had cookies from a lynx session. So, I copied my .lynx_cookies file to the ~aolserver directory, made aolserver the owner of the file, and added the following lines:
proc ns_Chttpget {url {timeout 30} {depth 0} {rqset ""}} {
if {[incr depth] > 10} {
return -code error "ns_Chttpget: Recursive redirection: $url"
}
#
# Perform the actual request.
#
ns_log Notice "ns_Chttpget: trying $url"
regexp {([^:]+)://([^:/]+)(:([0-9]+))?(/.*)} $url match protocol
server x port path
ns_log Notice "ns_Chttpget: $protocol $server $x $port $path"
set LynxFile [open /home/aolserv/.lynx_cookies r+ ]
set cookie {}
while {[gets $LynxFile line] >= 0} {
regexp {([^ ]+)[ ]+([^ ]+)[ ]+([^ ]+)[ ]+([^ ]+)[ ]+([^ ]+)
[ ]+([^ ]+)[ ]+([^ ]+)} $line lynxline lx_domain lx_false lx_path
lx_false2 lx_date lx_name lx_value
if {[string compare $server $lx_domain] == 0} {
ns_log Notice "Setting cookie: $lx_name=$lx_value"
append cookie "$lx_name=$lx_value; "
}
}
close $LynxFile
ns_log Notice "cookie: $cookie for X${server}X AKA X${lx_domain}X"
if {$rqset != ""} {
ns_set cput $rqset "Cookie" $cookie
set http [ns_Chttpopen GET $url $rqset $timeout]
} else {
set rqset2 [ns_set create]
ns_set cput $rqset2 "Cookie" $cookie
set http [ns_Chttpopen GET $url $rqset2 $timeout]
}
set rfd [lindex $http 0]
close [lindex $http 1]
set headers [lindex $http 2]
basically everything syncs up to the original hollyjerry version starting at "set rfd ..."
Also, first, in vi editor I did a :1,$s/ns_http/ns_Chttp/g just to avoid interfering with the original ns_http family of procs. Yes, the "C" stands for cookie. So shoot me ...
It ain't pretty, but it's working for me :)
Ideally, this would get extended out to actually WRITE the cookies that get sent back, but I don't need that functionality myself. Maybe someday Real Soon Now ... With all the fragmentation in the community, and also given that IMHO we should be using the http2.3 module rather than ns_http - it's hard to figure out who or where to contribute to!!! I can't post to the aolserver list - the majordomo won't accept me...
Final note after previewing - all the regexp statements are wrapped - they should only be one line long each!!
Request notifications