> Here's a bit of code from squid-2 src/client_side.c:
>
>         if (http->entry) {
>             if (EBIT_TEST(http->entry->flags, ENTRY_SPECIAL)) {
>                 httpHeaderDelById(hdr, HDR_DATE);
>                 httpHeaderInsertTime(hdr, 0, HDR_DATE, squid_curtime);
>             } else if (http->entry->timestamp < 0) {
>                 (void) 0;
>             } else if (http->conn->port->act_as_origin) {
>                 HttpHeaderEntry *h = httpHeaderFindEntry(hdr, HDR_DATE);
>                 if (h)
>                     httpHeaderPutExt(hdr, "X-Origin-Date",
> strBuf(h->value));
>                 httpHeaderDelById(hdr, HDR_DATE);
>                 httpHeaderInsertTime(hdr, 0, HDR_DATE, squid_curtime);
>                 h = httpHeaderFindEntry(hdr, HDR_EXPIRES);
>                 if (h && http->entry->expires >= 0) {
>                     httpHeaderPutExt(hdr, "X-Origin-Expires",
> strBuf(h->value));
>                     httpHeaderDelById(hdr, HDR_EXPIRES);
>                     httpHeaderInsertTime(hdr, 1, HDR_EXPIRES,
> squid_curtime + http->entry->expires -
> http->entry->timestamp);
>                 } {
>
> Why/where is the code assuming that offset 0 will be HDR_DATE and offset 1
> will
> be HDR_EXPIRES? The replacement code doesn't check to see whether anything
> is
> at the position in the array that its inserting into..
>
> Would it make more sense to modify httpHeaderDelById() to return the first
> offset
> it found a header of that type at and then make httpHeaderInsertTime() use
> that?
> Or perhaps replace that with a httpHeaderReplaceEntry() to replace an
> entry at
> that position? httpHeaderInsertEntry() is only used by
> httpHeaderInsertTime();
> httpHeaderInsertTime() is only ever called in the above snippet of code.
>
> Thanks,

Don't take me as authoritative on this (I'm using my knowledge of SMTP
headers as aplied to this).
But some specs reuire that all newly added headers fro a particular hop
get insetred at the top of the headers. That would cause header 0-1 to be
the new ones and the rest shuffle down. As performed by that code snippet.


Amos


Reply via email to