Re: Modifying Set-Cookie header in Squid 3.3.9

From: Alex Rousskov <rousskov_at_measurement-factory.com>
Date: Thu, 24 Apr 2014 08:20:36 -0600

On 04/24/2014 04:33 AM, Peter Belau wrote:

> I'm trying to modify the Set-Cookie header from within
> client_side_reply.cc. Currently my code looks like this:

> HttpReply *rep = http->storeEntry()->getReply()->clone();
> http->storeEntry()->releaseRequest();
> rep->header.putStr(HDR_SET_COOKIE, "FOO=bar");
> http->storeEntry()->replaceHttpReply(rep);
> http->storeEntry()->complete();

> This seems to corrupt storeEntry in ways that I don't understand. I
> imagine that I'm missing something fundamental here. If someone could
> point me in the right direct, I would much appreciate it.

Hi Peter,

    There are at least two fundamental problems here:

* As Eliezer has already noted, you should be using one of the many
available adaptation interfaces instead of modifying sources directly.
If the available interfaces do not do what you want, they usually can be
enhanced (or new interfaces can be added). As you said, we all have
specific reasons for doing the wrong thing, of course.

* If you want to adjust each response, including HIT responses, you
should be modifying the response as it goes out, not the Store entry
itself. See clientReplyContext::buildReplyHeader(). If you want to
adjust the response before it may be cached (so that a cached response
is adjusted just once and served many times), then you should be doing
that in http.cc instead.

HTH,

Alex.
Received on Thu Apr 24 2014 - 14:20:55 MDT

This archive was generated by hypermail 2.2.0 : Fri Apr 25 2014 - 12:00:16 MDT