--------------------- PatchSet 1945 Date: 2005/10/10 16:59:25 Author: rousskov Branch: squid3-icap Tag: (none) Log: - Do not send last-chunk when no body was expected (and, hence, when null-body was used). It is not yet clear whether zero-size preview is compatible with null-body. - Fixed ICAPPreview enable() which was not updating theState. - Use virginBody data member (which is computed once) instead of the expectVirginBody() method. - Added Preview debugging. Members: src/ICAPXaction.cc:1.1.2.47->1.1.2.48 src/ICAPXaction.h:1.1.2.24->1.1.2.25 Index: squid3/src/ICAPXaction.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/Attic/ICAPXaction.cc,v retrieving revision 1.1.2.47 retrieving revision 1.1.2.48 diff -u -r1.1.2.47 -r1.1.2.48 --- squid3/src/ICAPXaction.cc 7 Oct 2005 23:11:38 -0000 1.1.2.47 +++ squid3/src/ICAPXaction.cc 10 Oct 2005 16:59:25 -0000 1.1.2.48 @@ -351,7 +351,7 @@ const bool exhausted = state.doneReceiving && virginDataMgr.writeableSize(*body) <= 0; - if (exhausted || forceLast) { + if ((exhausted || forceLast) && virginBody.expected()) { debugs(93, 7, "ICAPXaction will write last-chunk of " << label); moveRequestChunk(&writeBuf, 0, forceLast); // adds zero-size chunk } @@ -989,7 +989,7 @@ if (const MsgPipeData::Header *prime = virgin->data->header) encapsulateHead(buf, "res-hdr", &httpBuf, prime); - if (!expectVirginBody()) + if (!virginBody.expected()) buf->Printf("null-body=%d", httpBuf.contentSize()); else if (m == ICAPServiceRep::reqmod) buf->Printf("req-body=%d", httpBuf.contentSize()); @@ -1038,8 +1038,12 @@ { size_t wantedSize; - if (!service->wantsPreview(wantedSize)) + if (!service->wantsPreview(wantedSize)) { + debugs(93, 5, "ICAPXaction should not offer preview"); return false; + } + + Must(wantedSize >= 0); // cannot preview more than we can backup size_t ad = XMIN(wantedSize, TheBackupLimit); @@ -1049,6 +1053,9 @@ else ad = 0; // questionable optimization? + debugs(93, 5, "ICAPXaction should offer " << ad << "-byte preview " << + "(service wanted: " << wantedSize << ")"); + preview.enable(ad); return preview.enabled(); @@ -1170,29 +1177,6 @@ section, ',').size() > 0; } -/* - * Indicate whether or not there is a virgin HTTP body associated with - * this ICAP transaction - */ -bool ICAPXaction::expectVirginBody() const -{ - if (virgin->data->header == NULL) - return false; - - ssize_t unused; - - method_t method; - - if (virgin->data->cause) { - method = virgin->data->cause->method; - } else { - HttpRequest *req= dynamic_cast(virgin->data->header); - method = req->method; - } - - return virgin->data->header->expectingBody(method, unused); -} - // calculate whether there is a virgin HTTP body and // whether its expected size is known void ICAPXaction::estimateVirginBody() @@ -1377,6 +1361,7 @@ Must(anAd >= 0); Must(!enabled()); theAd = anAd; + theState = stWriting; } bool ICAPPreview::enabled() const Index: squid3/src/ICAPXaction.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/Attic/ICAPXaction.h,v retrieving revision 1.1.2.24 retrieving revision 1.1.2.25 diff -u -r1.1.2.24 -r1.1.2.25 --- squid3/src/ICAPXaction.h 7 Oct 2005 23:11:38 -0000 1.1.2.24 +++ squid3/src/ICAPXaction.h 10 Oct 2005 16:59:25 -0000 1.1.2.25 @@ -1,6 +1,6 @@ /* - * $Id: ICAPXaction.h,v 1.1.2.24 2005/10/07 23:11:38 rousskov Exp $ + * $Id: ICAPXaction.h,v 1.1.2.25 2005/10/10 16:59:25 rousskov Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -199,7 +199,6 @@ void parseBody(); bool parsePresentBody(); void maybeAllocateHttpMsg(); - bool expectVirginBody() const; void handle100Continue(); void handle200Ok();