squid-3 icap related patch

From: Tsantilas Christos <chtsanti@dont-contact.us>
Date: Thu, 28 Sep 2006 05:18:11 -0400 (EDT)

Hi all,

I am sending a small patch for icap client.
With this patch squid-icap works for me (using 1-2 clients).
I will test it more under load, using different scenarios.

At the following lines I am trying to explain my changes:

1) File HttpReply.cc in function HttpReply::reset

pstate need to initialized again to psReadyToParseStartLine

2) Files http.c and ftp.c functions HttpStateData::doneAdapting,
HttpStateData::abortAdapting, FtpStateData::doneAdapting and
FtpStateData::abortAdapting

I comment out cbdataReferenceDone function call. I did not found any
cbdataReferenceValid call or something similar so I believe I am correct
here.

3) File ICAP/ICAPModXact.cc function ICAPModXact::handleCommWroteHeaders()

Sometimes, we have read the headers but not any part of the body yet so
in this case we must not call writeMore() function.

- writeMore();
+ if(virgin->data->body && virgin->data->body->contentSize())
+ writeMore();

4) File ICAP/ICAPModXact.cc function ICAPModXact::moveRequestChunk

The preview.wrote(chunkSize, state.doneReceiving) statement is not correct,
becouse we can have all the data but we did not send all the data yet.

My patch is:

+ const bool done = state.doneReceiving && claimSize(virginWriteClaim)
<= 0;
     if (state.writing == State::writingPreview)
- preview.wrote(chunkSize, state.doneReceiving); // even if wrote
nothing
+ preview.wrote(chunkSize, done); // even if wrote nothing

5) File ICAP/ICAPModXact.cc function ICAPModXact::addLastRequestChunk

The last chunk was not correct ("0\r\n; ieof\r\n" instead of "0;
ieof\r\n\r\n" ).

6) File ICAP/ICAPModXact.cc function ICAPModXact::handle100Continue

This function called when we read "100 Continue" responce from icap server.
After that we expect to read the real ICAP responce (ICAP headers
followed by http headers and http body).
In current implementation squid ICAP client expects to read the http headers.
The solution is:
- state.parsing = State::psHttpHeader; // eventually
+ state.parsing = State::psIcapHeader;
+ icapReply->reset();

7) File ICAP/ICAPModXact.cc function ICAPModXact::estimateVirginBody

if function header->expectingBody(method, size) returns size==0 then
we do not expect a body.

8) File ICAP/ICAPModXact.cc function ICAPPreview::enable

The theAd is the expected preview size so if theAd==0 do not
enable preview mode.

- theState = stWriting;
+ if(theAd >0)
+ theState = stWriting;
+ else
+ theState = stDisabled;

Received on Thu Sep 28 2006 - 03:18:23 MDT

This archive was generated by hypermail pre-2.1.9 : Sun Oct 01 2006 - 12:00:06 MDT