Hi - Tom suggested deleting the keys before adding them, but I don't
think this will work because fastpath is being invoked after the TCL
executes.  No matter what you do in TCL, if fastpath runs afterwards,
the current code will add a new Last-Modified header.  Haven't
verified this - just my belief as to how things work.

ns_return is a different case and should not give you duplicate
headers, because fastpath isn't invoked (again, not verified).

My guess is that the original developers envisioned fastpath to be
used only for static file serving where the server has complete
control of things and didn't take into account the cases of filters
and ns_returnfile with regard to header handling, so they assumed
there would be no output headers other than the ones the core server
was inserting.

This conditional header change will give developers extra poewr to
break things too, for example, you could insert a Content-Type header
that said text/html and then do a returnfile image/gif.  With the old
AS code, this would give you two headers.  With the new code you'll
get a single (wrong) header, text/html.

Jim

>
> On Tue, 2004-01-27 at 22:39, Andrew Spencer wrote:
> > Hello,
> >
> > > For 3.4x, look in nsd/return.c and nsd/fastpath.c; fastpath is calling
> > > Ns_ConnSetLastModifiedHeader in return.c to set Last-Modified.
> >
> > Thank you very much for the head start.
> >
> > > This routine calls Ns_ConnSetHeaders, which does an ns_set put, but it
> > > could easily call Ns_ConnCondSetHeaders, which would only do the put
> > > if the header doesn't exist.
> >
> > I see nothing wrong with this solution, and feel that perhaps it should
> > have been this way in the first place. That begs the question however:
> > why is Ns_ConnSetHeaders used instead of Ns_ConnCondSetHeaders in these
> > instances? Was there a specific reason? Are we going to break some
> > existing functionality by changing? (The latter seems doubtful
> > thankfully.)
> >
> > > Are you executing your TCL stuff in a filter/trace?  Or doing an
> > > ns_returnfile?  Those are the only ways I can see where you would be
> > > executing TCL to affect the headers but still ending up in the
> > > fastpath code.
> >
> > I've not tried in a trace, but a simple ADP page doing "ns_set update"
> > demonstrates the duplicate header behavior. The behavior is also evident
> > using ns_return and ns_returnfile. And as Daniel has pointed out,
> > ns_respond as well.
> >
> > > I've had a similar problem in the past: I needed to do an
> > > ns_returnfile, but didn't want the Last-Modified header to be sent out
> > > at all because I didn't want the result cached.  Never figured out
> > > how to do that.
> >
> > One would assume "ns_set delkey [ns_conn outputheaders] Last-Modified"
> > would work, but of course doesn't for similar reasons as the duplicate
> > issue.
> >
> If you have multiple keys of the same name, you need to delete all of
> them, a form set is similar:
>
> while {[set index [ns_set ifind [ns_conn form] forum_id]] > -1} {
>     ns_set delete [ns_conn form] $index
> }
>
> After you delete all the headers of a given name, you can add one if
> needed, with the correct value.
>
> I think the output header set is returned from [ns_conn outputheaders].
>
> tom jackson
>
>
> > I'm going to make the change Jim suggested and see if that fixes the
> > issue without breaking anything else. Thanks again!
> >
> >
> > --
> > 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.
>


--
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