[squid-users] RE: Incorrect parsing logic while handling ICAP REQMOD responses

From: Shree Raman <Shree_Raman_at_symantec.com>
Date: Wed, 27 May 2009 05:37:12 -0700

Thanks Alex that helped.

Regards,
Shree

-----Original Message-----
From: Alex Rousskov [mailto:rousskov_at_measurement-factory.com]
Sent: Wednesday, May 27, 2009 12:34 PM
To: Shree Raman
Cc: squid-users_at_squid-cache.org; Amos Jeffries
Subject: Re: Incorrect parsing logic while handling ICAP REQMOD
responses

On 05/27/2009 12:25 AM, Shree Raman wrote:
> Hello everyone,
>
> I am trying to use Squid as an ICAP client. I have moved to
> Squid-3.1.0.8 (latest beta release). I have noticed that some of the
> functionalities which worked for in Squid-3.0.Stable13 do not function
> as expected with this latest release (Squid-3.1.0.8).
>
> I made a debug build of squid and did a step through in the code to
> discover the problem. This issue was experienced when squid sends an
> ICAP reqmod request encapsulating a HTTP Post request to be sent an
> external server in the Internet and the ICAP Server responds back with
> an HTTP response (encapsulated in ICAP response) on behalf of external
> server. Loosely, it is equivalent of Example 3 in section 4.8.3 of RFC
> 3507.
>
> A step through in the build of Squid revealed that while parsing the
> received ICAP response, Squid was expecting an HTTP Request and not a
> HTTP Response (as sent by ICAP server on behalf of external server).
> Issue is seen when parseFirstLine() method (line 259 of HttpMsg.cc) is
> invoked in HttpMsg::httpMsgParseStep() method. Shouldn't there be a
> logic to check the first line of HTTP header and determine whether it
> should use HttpReply or HttpRequest class. I haven't developed a good
> knowledge to create a fix/patch for this issue. If any pro can provide
> some reference/guidance, then I can develop the fix.
>
> If you may need more information to help resolving this issue, then
> please send me an email.

The ICAP Encapsulated header determines the type of the HTTP message
inside the ICAP response. Can you check that the ICAP response Squid
receives has the right Encapsulated header (res-hdr versus req-hdr)?

In the slightly stale code I have looked at, Icap::ModXact creates
HttpRequest or HttpReply object depending on the ICAP Encapsulated
header value (see the maybeAllocateHttpMsg() method). Each HttpMsg kid
has its own parseFirstLine() method so the right first line parser
should be called if the object of the right type is created.

Please note that ICAP code uses HttpRequest parser for the ICAP headers.
This happens before the HTTP headers are parsed.

Thank you,

Alex.
Received on Wed May 27 2009 - 12:37:42 MDT

This archive was generated by hypermail 2.2.0 : Wed May 27 2009 - 12:00:02 MDT