Re: [PATCH] meta_header option

From: Tsantilas Christos <chtsanti_at_users.sourceforge.net>
Date: Fri, 21 Sep 2012 16:12:30 +0300

Hi Amos,

On 09/21/2012 12:31 PM, Amos Jeffries wrote:
> On 21/09/2012 4:56 a.m., Tsantilas Christos wrote:
>> On 09/20/2012 08:56 AM, Amos Jeffries wrote:
>>
>>> * also, how can theVirginRep.raw().header be cast to both Request and
>>> Reply without one being wrong? surely the second should be
>>> const HttpReply *reply = NULL;
>>> if (theCauseRep)
>>> reply = dynamic_cast<const
>>> HttpReply*>(theVirginRep.raw().header);
>> It is a part of code used in many places inside ecap and icap.
>
> Add this to your code to see what I mean:
>
> if (!theCauseRep)
> assert(request == reply);

The assertion will fail.

It is the dynamic_cast operator who make the job here. This operator
does a type checking. Will return NULL if the conversion is not possible.

Assume the following:
HttpRequest *req = dynamic_cast<HttpRequest*>(theVirginRep.raw().header);
HttpReply *rep = dynamic_cast<HttpReply*>(theVirginRep.raw().header);

If the theVirginRep.raw().header is an HttpReply object the req will be
NULL else if it is an HttpRequest object the rep will be NULL.

Is it something else I am not seeing here?

>
> in the patch as submitted previously the assert will be tested on
> requests. I dont expect it to stop squid running though.
>
> Due to:
>
> HttpRequest*request = ... theVirginRep.raw().header);
> HttpReply*reply = ...theVirginRep.raw().header);
>
> Amos
Received on Fri Sep 21 2012 - 13:12:55 MDT

This archive was generated by hypermail 2.2.0 : Fri Sep 21 2012 - 12:00:07 MDT