--------------------- PatchSet 6016 Date: 2003/11/06 06:41:12 Author: dwsquid Branch: icap-2_5 Tag: (none) Log: handle the case when http.c doesn't get the full HTTP response headers in the first read(). HTTP response headers are buffered (they were already being copied) and the ICAP request is not sent until we get to the end of the reply headers. Members: src/icap_respmod.c:1.1.2.14->1.1.2.15 Index: squid/src/icap_respmod.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/Attic/icap_respmod.c,v retrieving revision 1.1.2.14 retrieving revision 1.1.2.15 diff -u -r1.1.2.14 -r1.1.2.15 --- squid/src/icap_respmod.c 4 Nov 2003 18:22:33 -0000 1.1.2.14 +++ squid/src/icap_respmod.c 6 Nov 2003 06:41:12 -0000 1.1.2.15 @@ -1,5 +1,5 @@ /* - * $Id: icap_respmod.c,v 1.1.2.14 2003/11/04 18:22:33 dwsquid Exp $ + * $Id: icap_respmod.c,v 1.1.2.15 2003/11/06 06:41:12 dwsquid Exp $ * * DEBUG: section 81 Internet Content Adaptation Protocol (ICAP) Client * AUTHOR: Geetha Manjunath, Hewlett Packard Company @@ -79,6 +79,18 @@ int hlen = 0; icap_service *service; + if (memBufIsNull(&icap->respmod.req_hdr_copy)) + memBufDefInit(&icap->respmod.req_hdr_copy); + + hlen = headersEnd(buf, len); + if (0 == hlen) { + /* didn't get end of HTTP response headers yet */ + memBufAppend(&icap->respmod.req_hdr_copy, buf, len); + return 0; + } else { + memBufAppend(&icap->respmod.req_hdr_copy, buf, hlen); + } + /* Copy request header */ memBufDefInit(&mb_hdr); httpBuildRequestPrefix(icap->request, icap->request, @@ -86,17 +98,11 @@ o2 = mb_hdr.size; /* Copy response header - Append to request header mbuffer */ - hlen = headersEnd(buf, len); - if (hlen) { - memBufDefInit(&icap->respmod.req_hdr_copy); - memBufAppend(&icap->respmod.req_hdr_copy, buf, hlen); - memBufAppend(&mb_hdr, buf, hlen); - o3 = mb_hdr.size; - len -= hlen; - } else { - o3 = o2; - o2 = -1; - } + memBufAppend(&mb_hdr, + icap->respmod.req_hdr_copy.buf, + icap->respmod.req_hdr_copy.size); + o3 = mb_hdr.size; + len -= hlen; service = icap->current_service; assert(service); @@ -182,6 +188,11 @@ buf += icap->sc; len -= icap->sc; } + if (0 == icap->sc) { + /* check again; bail if we're not ready to send ICAP/HTTP hdrs */ + debug(81, 5) ("icapSendRespMod: dont have full HTTP response hdrs\n"); + return 0; + } #if ICAP_PREVIEW if (preview_size < 0) /* preview feature off */ icap->flags.preview_done = 1;