--------------------- PatchSet 6256 Date: 2004/08/04 17:13:00 Author: dwsquid Branch: icap-2_5 Tag: (none) Log: Patch From olivier - Fixes for RESPMOD preview mode. - Show ICAP FD instead of HTTP FD in debugging - Call commSetSelect on ICAP data instead of HTTP data - Reset ICAP header buffer - don't send ieof chunk for RESPMOD if null-body Members: src/icap_respmod.c:1.1.2.36->1.1.2.37 Index: squid/src/icap_respmod.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/Attic/icap_respmod.c,v retrieving revision 1.1.2.36 retrieving revision 1.1.2.37 diff -u -r1.1.2.36 -r1.1.2.37 --- squid/src/icap_respmod.c 4 Aug 2004 17:02:25 -0000 1.1.2.36 +++ squid/src/icap_respmod.c 4 Aug 2004 17:13:00 -0000 1.1.2.37 @@ -1,6 +1,6 @@ /* - * $Id: icap_respmod.c,v 1.1.2.36 2004/08/04 17:02:25 dwsquid Exp $ + * $Id: icap_respmod.c,v 1.1.2.37 2004/08/04 17:13:00 dwsquid Exp $ * * DEBUG: section 81 Internet Content Adaptation Protocol (ICAP) Client * AUTHOR: Geetha Manjunath, Hewlett Packard Company @@ -241,7 +241,7 @@ if (size > preview_size + 1) size = preview_size + 1; size -= icap->respmod.buffer.size; - debug(81, 3) ("icapSendRespMod: FD %d: copy %d more bytes to preview buffer.\n", icap->http_fd, size); + debug(81, 3) ("icapSendRespMod: FD %d: copy %d more bytes to preview buffer.\n", icap->icap_fd, size); memBufAppend(&icap->respmod.buffer, buf, size); buf = ((char *) buf) + size; len -= size; @@ -260,7 +260,8 @@ } if (icap->respmod.buffer.size <= preview_size) { /* content length is less than preview size+1 */ - memBufAppend(&mb, "0; ieof\r\n\r\n", 11); + if (icap->respmod.res_body_sz) + memBufAppend(&mb, "0; ieof\r\n\r\n", 11); memBufReset(&icap->respmod.buffer); /* will now be used for other data */ } else { char ch; @@ -271,7 +272,7 @@ ch = icap->respmod.buffer.buf[preview_size]; memBufReset(&icap->respmod.buffer); /* will now be used for other data */ memBufAppend(&icap->respmod.buffer, &ch, 1); - debug(81, 3) ("icapSendRespMod: FD %d: sending preview and keeping %d bytes in internal buf.\n", icap->http_fd, len + 1); + debug(81, 3) ("icapSendRespMod: FD %d: sending preview and keeping %d bytes in internal buf.\n", icap->icap_fd, len + 1); if (len > 0) memBufAppend(&icap->respmod.buffer, buf, len); } @@ -281,15 +282,15 @@ } else if (icap->flags.wait_for_preview_reply) { /* received new data while waiting for preview response */ /* add data to internal buffer and send later */ - debug(81, 3) ("icapSendRespMod: FD %d: add %d more bytes to internal buf while wiaiting for preview-response.\n", icap->http_fd, len); + debug(81, 3) ("icapSendRespMod: FD %d: add %d more bytes to internal buf while wiaiting for preview-response.\n", icap->icap_fd, len); if (len > 0) memBufAppend(&icap->respmod.buffer, buf, len); /* do not send any data now while waiting for preview response */ /* but prepare for read more data on the HTTP connection */ if (!icap->flags.http_server_eof) { - debug(81, 3) ("icapSendRespMod: FD %d: commSetSelect on read httpReadReply waiting for preview response.\n", icap->http_fd); - commSetSelect(icap->http_fd, COMM_SELECT_READ, httpReadReply, - httpState, 0); + debug(81, 3) ("icapSendRespMod: FD %d: commSetSelect on read icapRespModReadReply waiting for preview response.\n", icap->icap_fd); + commSetSelect(icap->icap_fd, COMM_SELECT_READ, icapRespModReadReply, + icap, 0); } return; } else @@ -396,6 +397,11 @@ * was received while waiting fot this ICAP response */ icapSendRespMod(icap, NULL, 0, 0); + /* + * reset the header to send the rest of the preview + */ + if (!memBufIsNull(&icap->icap_hdr)) + memBufReset(&icap->icap_hdr); return; #if SUPPORT_ICAP_204 } else if (status == 204) {