--------------------- PatchSet 4304 Date: 2007/04/21 03:50:28 Author: rousskov Branch: squid3-icap Tag: (none) Log: Make sure the entire response body gets to ICAP, even when the end of it does not fit into the BodyPipe buffer. Re-enabled code that limits the amount of data the server may read depending on the available ICAP BodyPipe buffer size. While new BodyPipes limit the amount of data they accept, we still need the external limit because there is no code to keep pumping data into the pipe once the HTTP response ends and serverComplete() is called. If any body data is left in the HTTP server read buffer at the serverComplete() time, that data is lost and the client gets a truncated response. It is not clear whether it is better to stall the faster HTTP server I/O to let the slower ICAP server consume the body from the pipe OR to add code that will drain leftovers from the HTTP read buffer into the pipe. Members: src/http.cc:1.49.2.65->1.49.2.66 Index: squid3/src/http.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/http.cc,v retrieving revision 1.49.2.65 retrieving revision 1.49.2.66 diff -u -r1.49.2.65 -r1.49.2.66 --- squid3/src/http.cc 16 Apr 2007 19:47:56 -0000 1.49.2.65 +++ squid3/src/http.cc 21 Apr 2007 03:50:28 -0000 1.49.2.66 @@ -1,6 +1,6 @@ /* - * $Id: http.cc,v 1.49.2.65 2007/04/16 19:47:56 rousskov Exp $ + * $Id: http.cc,v 1.49.2.66 2007/04/21 03:50:28 rousskov Exp $ * * DEBUG: section 11 Hypertext Transfer Protocol (HTTP) * AUTHOR: Harvest Derived @@ -1226,17 +1226,18 @@ int read_sz = readBuf->spaceSize(); #if ICAP_CLIENT -#if RE_ENABLE_THIS_IF_NEEDED_OR_DELETE - // This code is not broken, but is probably not needed because we - // probably can read more than will fit into the BodyPipe buffer. - if (virginBodyDestination != NULL) { /* * BodyPipe buffer has a finite size limit. We * should not read more data from the network than will fit - * into the pipe buffer. If totally full, don't register - * the read handler at all. The ICAP side will call our - * icapSpaceAvailable() method when it has free space again. + * into the pipe buffer or we _lose_ what did not fit if + * the response ends sooner that BodyPipe frees up space: + * There is no code to keep pumping data into the pipe once + * response ends and serverComplete() is called. + * + * If the pipe is totally full, don't register the read handler. + * The BodyPipe will call our noteMoreBodySpaceAvailable() method + * when it has free space again. */ int icap_space = virginBodyDestination->buf().potentialSpaceSize(); @@ -1246,8 +1247,6 @@ if (icap_space < read_sz) read_sz = icap_space; } - -#endif #endif debugs(11,9, HERE << (flags.do_next_read ? "may" : "wont") <<