--------------------- PatchSet 6033 Date: 2003/11/14 00:37:35 Author: dwsquid Branch: icap-2_5 Tag: (none) Log: fixed a bug with ICAP 204 responses and HTTP replies with content-length 0. Detect the end of the ICAP response and don't let the connection timeout. Members: src/icap_respmod.c:1.1.2.21->1.1.2.22 Index: squid/src/icap_respmod.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/Attic/icap_respmod.c,v retrieving revision 1.1.2.21 retrieving revision 1.1.2.22 diff -u -r1.1.2.21 -r1.1.2.22 --- squid/src/icap_respmod.c 13 Nov 2003 23:48:54 -0000 1.1.2.21 +++ squid/src/icap_respmod.c 14 Nov 2003 00:37:35 -0000 1.1.2.22 @@ -1,5 +1,5 @@ /* - * $Id: icap_respmod.c,v 1.1.2.21 2003/11/13 23:48:54 dwsquid Exp $ + * $Id: icap_respmod.c,v 1.1.2.22 2003/11/14 00:37:35 dwsquid Exp $ * * DEBUG: section 81 Internet Content Adaptation Protocol (ICAP) Client * AUTHOR: Geetha Manjunath, Hewlett Packard Company @@ -179,8 +179,12 @@ return 0; return 1; } - if (theEnd) - icap->flags.send_zero_chunk = 1; + if (theEnd) { + if (icap->respmod.res_body_sz) + icap->flags.send_zero_chunk = 1; + else + icap->flags.http_server_eof = 1; + } /* * httpReadReply is going to call us with a chunk and then * right away again with an EOF if httpPconnTransferDone() is true. @@ -301,7 +305,7 @@ memBufAppend(&mb, crlf, 2); icap->sc += len; } - if (icap->flags.send_zero_chunk && icap->respmod.res_body_sz) { + if (icap->flags.send_zero_chunk) { /* send zero end chunk */ icap->flags.send_zero_chunk = 0; icap->flags.http_server_eof = 1; @@ -314,11 +318,13 @@ } commSetTimeout(icap->icap_fd, -1, NULL, NULL); + if (mb.size) { #if 1 - debug(81, 5) ("icapSendRespMod: FD %d writing {%s}\n", icap->icap_fd, mb.buf); + debug(81, 5) ("icapSendRespMod: FD %d writing {%s}\n", icap->icap_fd, mb.buf); #endif - icap->flags.write_pending = 1; - comm_write_mbuf(icap->icap_fd, mb, icapSendRespModDone, icap); + icap->flags.write_pending = 1; + comm_write_mbuf(icap->icap_fd, mb, icapSendRespModDone, icap); + } return 1; } @@ -675,18 +681,15 @@ debug(81, 5) ("icapPconnTransferDone: keep_alive not set, ret 0\n"); return 0; } -#if 0 /* - * Disabling this because it breaks for large responses that dont - * fit entirely into the resp_copy MemBuf. If we return 1 here, - * the ICAP state is freed and any further data coming from the - * client side gets lost. + * Be careful with 204 responses. Normally we are done when we + * see the zero-end chunk, but that won't happen for 204s, so we + * use an EOF indicator on the HTTP side instead. */ - if (icap->flags.no_content) { + if (icap->flags.no_content && icap->flags.http_server_eof) { debug(81, 5) ("icapPconnTransferDone: no content, ret 1\n"); return 1; } -#endif if (icapHttpReplyHdrState(icap) != 2) { debug(81, 5) ("icapPconnTransferDone: didn't see end of HTTP hdrs, ret 0\n"); return 0;