Ian,

You could never use the code below because the body is generated prior
 to any headers. The last thing to be called is ns_return. I haven't looked 
further 
into your example, but you would need to actually do a manual request to see 
what
 is returned, like using:

curl -I (that is a capitol i).

or wget... or telnet.

This page has a proc ::cookie::setCookie which uses output headers:
http://rmadilo.com/m2/servers/rmadilo/modules/tcl/twt/packages/cookie/tcl/cookie-procs.tcl

You can visit any page on this site and see that you can add headers to the 
set, and still get the standard ones (example):

HTTP/1.1 200 OK
Set-Cookie: SessionID = "50A998109100883774F13E2095304923B93D51C5" ; Max-Age = 
867577991 ; Path=/
Set-Cookie2: SessionID = "50A998109100883774F13E2095304923B93D51C5" ; Max-Age = 
867577991 ; Path=/ ; Version = 1
MIME-Version: 1.0
Date: Thu, 05 Jul 2007 15:06:50 GMT
Server: AOLserver/4.5.0
Content-Type: text/xml; charset=UTF-8
Content-Length: 380
Connection: close



On Thursday 05 July 2007 07:53, Ian Harding wrote:
> From the documentation it looks like ns_conn outputheaders "Returns an
> ns_set containing the headers that will be sent out when a result is
> returned to the client."
>
> I can't get it to return anything but an empty set.  All the examples
> I see are of people writing to the set to add or overwrite headers,
> but not anyone looking at the "...Headers that will be sent out..."
>
> I see lots of examples of homemade headers to be sent out in advance
> of ns_write to stream data to clients.  I was hoping to be able to use
> ns_conn returnheaders to get a nice pre-built set of headers that
> AOLServer would have used in the case of, say, ns_return, that I could
> ns_write without having to cobble together my own homebrew headers.
>
> Should this work?
>
> ns_register_proc GET /foobar headers
> proc headers {} {
>         set headers [ns_conn outputheaders]
>         set html "Output headers are:<br>"
>         for {set i 0} {$i < [ns_set size $headers]} {incr i} {
>                 append html "[ns_set key $headers $i] is [ns_set value
> $headers $i]<br>"
>         }
>         ns_return 200 text/html $html
> }
>
> It works for ns_conn headers, but not outputheaders.  If this is by
> design, I think the documentation should be made clear that this
> ns_set is empty and that any data added to it will overwrite or append
> to the output headers.
>
> Or I'm just doing it wrong...
>
> Thanks,
>
> - Ian
>
>
> --
> AOLserver - http://www.aolserver.com/
>
> To Remove yourself from this list, simply send an email to
> <[EMAIL PROTECTED]> with the body of "SIGNOFF AOLSERVER" in the
> email message. You can leave the Subject: field of your email blank.


--
AOLserver - http://www.aolserver.com/

To Remove yourself from this list, simply send an email to <[EMAIL PROTECTED]> 
with the
body of "SIGNOFF AOLSERVER" in the email message. You can leave the Subject: 
field of your email blank.

Reply via email to