--------------------- PatchSet 6118 Date: 2004/01/14 08:23:21 Author: rhorstmann Branch: icap-2_5 Tag: (none) Log: some icap servers seem to ignore the "Connection: close" header for options request. so after getting the complete options reply we close the connection ourself now. Members: src/String.c:1.4.78.1->1.4.78.2 src/defines.h:1.15.6.3.6.1->1.15.6.3.6.2 src/icap_opt.c:1.1.2.9->1.1.2.10 src/icap_respmod.c:1.1.2.30->1.1.2.31 src/structs.h:1.48.2.9.2.24->1.48.2.9.2.25 Index: squid/src/String.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/String.c,v retrieving revision 1.4.78.1 retrieving revision 1.4.78.2 diff -u -r1.4.78.1 -r1.4.78.2 --- squid/src/String.c 28 Nov 2003 13:47:11 -0000 1.4.78.1 +++ squid/src/String.c 14 Jan 2004 08:23:21 -0000 1.4.78.2 @@ -1,7 +1,8 @@ + /* - * $Id: String.c,v 1.4.78.1 2003/11/28 13:47:11 rhorstmann Exp $ + * $Id: String.c,v 1.4.78.2 2004/01/14 08:23:21 rhorstmann Exp $ * * DEBUG: section 67 String * AUTHOR: Duane Wessels Index: squid/src/defines.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/defines.h,v retrieving revision 1.15.6.3.6.1 retrieving revision 1.15.6.3.6.2 diff -u -r1.15.6.3.6.1 -r1.15.6.3.6.2 --- squid/src/defines.h 28 Nov 2003 13:47:18 -0000 1.15.6.3.6.1 +++ squid/src/defines.h 14 Jan 2004 08:23:21 -0000 1.15.6.3.6.2 @@ -1,7 +1,8 @@ + /* - * $Id: defines.h,v 1.15.6.3.6.1 2003/11/28 13:47:18 rhorstmann Exp $ + * $Id: defines.h,v 1.15.6.3.6.2 2004/01/14 08:23:21 rhorstmann Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ Index: squid/src/icap_opt.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/Attic/icap_opt.c,v retrieving revision 1.1.2.9 retrieving revision 1.1.2.10 diff -u -r1.1.2.9 -r1.1.2.10 --- squid/src/icap_opt.c 13 Jan 2004 15:24:10 -0000 1.1.2.9 +++ squid/src/icap_opt.c 14 Jan 2004 08:23:21 -0000 1.1.2.10 @@ -1,6 +1,6 @@ /* - * $Id: icap_opt.c,v 1.1.2.9 2004/01/13 15:24:10 rhorstmann Exp $ + * $Id: icap_opt.c,v 1.1.2.10 2004/01/14 08:23:21 rhorstmann Exp $ * * DEBUG: section 81 Internet Content Adaptation Protocol (ICAP) Client OPTIONS * AUTHOR: Ralf Horstmann @@ -49,7 +49,7 @@ /* * reply parsing functions */ -static int icapOptParseReply(icap_service * s, const char *buf); +static int icapOptParseReply(icap_service * s, IcapOptData * i); static void icapOptParseEntry(icap_service * s, const char *blk_start, const char *blk_end); static int icapIsolateLine(const char **parse_start, const char **blk_start, const char **blk_end); @@ -97,7 +97,7 @@ icapOptSetUnreachable(icap_service * s) { s->unreachable = 1; - debug(81,5)("icapOptSetUnreachable: got called for %s\n", s->uri); + debug(81, 5) ("icapOptSetUnreachable: got called for %s\n", s->uri); /* * if there is an options request scheduled, delete it and add * it again to reset the time to the default check_interval. @@ -269,7 +269,16 @@ if (size > 0) { /* do some statistics */ fd_bytes(fd, size, FD_READ); - /* kb_incr(&statCounter.client_http.kbytes_in, size); */ + + /* + * some icap servers seem to ignore the "Connection: close" header. so + * after getting the complete option reply we close the connection + * ourself. + */ + if ((i->headlen = headersEnd(i->buf, i->offset))) { + debug(81, 3) ("icapOptReadReply: EndOfResponse\n"); + size = 0; + } } if (size < 0) { debug(81, 3) ("icapOptReadReply: FD %d: read failure: %s.\n", fd, xstrerror()); @@ -285,7 +294,7 @@ i->buf[i->offset] = '\0'; /* for string functions */ debug(81, 3) ("icapOptReadReply: unreachable=0, service=%s\n", s->uri); s->unreachable = 0; - if (icapOptParseReply(s, i->buf) && s->options_ttl > 0) { + if (icapOptParseReply(s, i) && s->options_ttl > 0) { debug(81, 3) ("icapOptReadReply: OPTIONS request successful. scheduling again in %d seconds\n", s->options_ttl); eventAdd("icapOptStart", icapOptStart, s, s->options_ttl, 1); } else { @@ -428,12 +437,12 @@ /* parse OPTIONS reply */ static int -icapOptParseReply(icap_service * s, const char *buf) +icapOptParseReply(icap_service * s, IcapOptData * i) { LOCAL_ARRAY(char, tmpbuf, SQUID_TCP_SO_RCVBUF); float ver; int status; - int headlen; + const char *buf = i->buf; const char *parse_start; const char *head_end; const char *blk_start; @@ -451,12 +460,14 @@ return 0; } parse_start = buf; - headlen = headersEnd(parse_start, s->opt->offset); - if (!headlen) { + if (i->headlen == 0) + i->headlen = headersEnd(parse_start, s->opt->offset); + + if (!i->headlen) { debug(81, 2) ("icapOptParseReply: end of headers could not be found\n"); return 0; } - head_end = parse_start + headlen - 1; + head_end = parse_start + i->headlen - 1; while (*(head_end - 1) == '\r') head_end--; assert(*(head_end - 1) == '\n'); @@ -483,6 +494,8 @@ icapOptDataInit(IcapOptData * i) { i->buf = memAllocBuf(HTTP_REPLY_BUF_SZ, &i->size); + i->offset = 0; + i->headlen = 0; } static void Index: squid/src/icap_respmod.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/Attic/icap_respmod.c,v retrieving revision 1.1.2.30 retrieving revision 1.1.2.31 diff -u -r1.1.2.30 -r1.1.2.31 --- squid/src/icap_respmod.c 13 Jan 2004 15:24:10 -0000 1.1.2.30 +++ squid/src/icap_respmod.c 14 Jan 2004 08:23:21 -0000 1.1.2.31 @@ -1,6 +1,6 @@ /* - * $Id: icap_respmod.c,v 1.1.2.30 2004/01/13 15:24:10 rhorstmann Exp $ + * $Id: icap_respmod.c,v 1.1.2.31 2004/01/14 08:23:21 rhorstmann Exp $ * * DEBUG: section 81 Internet Content Adaptation Protocol (ICAP) Client * AUTHOR: Geetha Manjunath, Hewlett Packard Company @@ -583,7 +583,7 @@ err->request = requestLink(icap->request); errorAppendEntry(icap->respmod.entry, err); comm_close(fd); - debug(81,3) ("icapConnectOver: status < 0, unreachable=1\n"); + debug(81, 3) ("icapConnectOver: status < 0, unreachable=1\n"); icapOptSetUnreachable(icap->current_service); return; } Index: squid/src/structs.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/structs.h,v retrieving revision 1.48.2.9.2.24 retrieving revision 1.48.2.9.2.25 diff -u -r1.48.2.9.2.24 -r1.48.2.9.2.25 --- squid/src/structs.h 28 Nov 2003 14:34:40 -0000 1.48.2.9.2.24 +++ squid/src/structs.h 14 Jan 2004 08:23:21 -0000 1.48.2.9.2.25 @@ -1,6 +1,6 @@ /* - * $Id: structs.h,v 1.48.2.9.2.24 2003/11/28 14:34:40 rhorstmann Exp $ + * $Id: structs.h,v 1.48.2.9.2.25 2004/01/14 08:23:21 rhorstmann Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -1100,6 +1100,7 @@ char *buf; off_t offset; size_t size; + off_t headlen; }; #endif