Forum OpenACS Q&A: Changing http headers

Posted by Michael Hinds on

I'm trying to add extra stuff into my outgoing http headers. I thought something like this might work:

ns_set put [ad_conn outputheaders] Cache-Control "max-age=3600, must-revalidate"

but it doesn't. Is there some way of specifying extra headers to Mr. Request Processor via the API? I don't want to have to revert back to doc_return or ns_return if I can help it!

TIA, Michael

Posted by Michael Hinds on
Oops! Actually it does work, but I suppose the question about the API still stands...
Posted by Michael A. Cleverly on
The request processor doesn't have anything magical in this regard, and if it did, it'd just be a short cut for what you typed above. Perhaps a short wrapper proc (to make things read more cleanly?) along the lines of:
    ad_proc append_outputheader {-overwrite:boolean key value} {
        Add an output header that will get written to the client
        connection.  Use -overwrite to update a key that already
        exists (without -overwrite a duplicate key results in 
        multiple headers being sent to the client which may very
        well be OK depending on the header).
    } {
        if {$overwrite_p} {
            ns_set update [ad_conn outputheaders] $key $value
        } else {
            ns_set put [ad_conn outputheaders] $key $value