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
