Forum OpenACS Q&A: Re: Using AOLserver as a proxy server

Collapse
Posted by Dan Mascenik on
ns_writefp was the command I was looking for. This does exactly what I wanted in that it streams data from some foreign server to the connection:
set conn [ns_httpopen GET $some_arbitrary_URL {} 30]
set read_desc [lindex $conn 0]
set write_desc [lindex $conn 1]
set headers [lindex $conn 2]

set mime_type [ns_set get $headers content-type]

set head "HTTP/1.0 200 OK
MIME-Version: 1.0
Content-Type: $mime_type\r\n\r\n"
# Plus any more headers you need.

ns_write $head
ns_startcontent -type $mime_type    
ns_writefp $read_desc

Thanks again, Tom!