--------------------- PatchSet 6577 Date: 2005/04/01 17:17:41 Author: chtsanti Branch: icap-2_5 Tag: (none) Log: ICAP request modifications corrections: In some cases the upload of data did not comlete: A stupid developer (chtsanti) had removed a piece of code which needed.... Many thanks to Mateus Groess which reports the problem and sents the required debuging info Members: src/icap_reqmod.c:1.1.2.41->1.1.2.42 Index: squid/src/icap_reqmod.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/Attic/icap_reqmod.c,v retrieving revision 1.1.2.41 retrieving revision 1.1.2.42 diff -u -r1.1.2.41 -r1.1.2.42 --- squid/src/icap_reqmod.c 31 Mar 2005 17:31:03 -0000 1.1.2.41 +++ squid/src/icap_reqmod.c 1 Apr 2005 17:17:41 -0000 1.1.2.42 @@ -1,6 +1,6 @@ /* - * $Id: icap_reqmod.c,v 1.1.2.41 2005/03/31 17:31:03 chtsanti Exp $ + * $Id: icap_reqmod.c,v 1.1.2.42 2005/04/01 17:17:41 chtsanti Exp $ * * DEBUG: section 81 Internet Content Adaptation Protocol (ICAP) Client * AUTHOR: Geetha Manjunath, Hewlett Packard Company @@ -46,12 +46,14 @@ int clientHierarchical(clientHttpRequest *); void clientReadBody(request_t * request, char *buf, size_t size, CBCB * callback, void *cbdata); +static void icapReqModPassHttpBody(IcapStateData * icap, char *buf, size_t size, + CBCB * callback, void *cbdata); static PF icapReqModReadHttpHdrs; static PF icapReqModReadHttpBody; static CWCB icapReqModSendBodyChunk; static CBCB icapReqModBodyHandler; -static BODY_HANDLER icapReqModPassHttpBody; +static BODY_HANDLER icapReqModBodyReader; static STRCB icapReqModMemBufAppend; #define EXPECTED_ICAP_HEADER_LEN 256 @@ -156,7 +158,7 @@ /* Do we expect a request-body? */ if (request->content_length > 0) { debug(81, 5) ("handing request bodies in ICAP REQMOD\n"); - request->body_reader = icapReqModPassHttpBody; + request->body_reader = icapReqModBodyReader; request->body_reader_data = icap; /* XXX cbdataLock? */ memBufDefInit(&icap->reqmod.http_entity.buf); } @@ -829,18 +831,14 @@ debug(81, 3) ("%s:%d http_entity.buf.size=%d\n", __FILE__, __LINE__, icap->reqmod.http_entity.buf.size); if (icap->reqmod.http_entity.callback && icap->reqmod.http_entity.buf.size) { - debug(81, 3) ("I think it is not possible .... (but when?:%s)\n", - icap->reqmod.http_entity.buf.buf); - /*Simply to duplicate the following function to take icap - * as first argument..... /chtsanti */ -/* icapReqModPassHttpBody(icap, - * icap->reqmod.http_entity.callback_buf, - * icap->reqmod.http_entity.callback_bufsize, - * icap->reqmod.http_entity.callback, - * icap->reqmod.http_entity.callback_data); - * icap->reqmod.http_entity.callback = NULL; - * cbdataUnlock(icap->reqmod.http_entity.callback_data); - */ + icapReqModPassHttpBody(icap, + icap->reqmod.http_entity.callback_buf, + icap->reqmod.http_entity.callback_bufsize, + icap->reqmod.http_entity.callback, + icap->reqmod.http_entity.callback_data); + icap->reqmod.http_entity.callback = NULL; + cbdataUnlock(icap->reqmod.http_entity.callback_data); + } } @@ -852,24 +850,23 @@ * body that were stored in the http_entity.buf MemBuf. */ static void -icapReqModPassHttpBody(request_t * request, char *buf, size_t size, +icapReqModPassHttpBody(IcapStateData * icap, char *buf, size_t size, CBCB * callback, void *cbdata) { - IcapStateData *icap = request->body_reader_data;; debug(81, 3) ("icapReqModPassHttpBody: called\n"); - if(!buf){ - debug(81,1) ("icapReqModPassHttpBody: FD %d called with %p, %d, %p (request aborted)\n", - icap->icap_fd,buf,(int)size,cbdata); - comm_close(icap->icap_fd); - return; + if (!buf) { + debug(81, 1) ("icapReqModPassHttpBody: FD %d called with %p, %d, %p (request aborted)\n", + icap->icap_fd, buf, (int) size, cbdata); + comm_close(icap->icap_fd); + return; } if (!cbdataValid(cbdata)) { debug(81, 1) ("icapReqModPassHttpBody: FD %d callback data invalid, closing\n", icap->icap_fd); - comm_close(icap->icap_fd); /*It is better to be sure that the connection will be closed.....*/ - /*icapReqModKeepAliveOrClose(icap);*/ + comm_close(icap->icap_fd); /*It is better to be sure that the connection will be closed..... */ + /*icapReqModKeepAliveOrClose(icap); */ return; } debug(81, 3) ("icapReqModPassHttpBody: entity buf size = %d\n", @@ -910,6 +907,21 @@ } /* + * Body reader handler for use with request->body_reader function + * The icapReqModPassHttpBody can used directly + * to the icap->request->body_reader with setting + * icap->request->body_reader_data=icap but the compiler complains.... + */ + +static void +icapReqModBodyReader(request_t * request, char *buf, size_t size, + CBCB * callback, void *cbdata) +{ + IcapStateData *icap = request->body_reader_data; + icapReqModPassHttpBody(icap, buf, size, callback, cbdata); +} + +/* * icapReqModMemBufAppend * * stupid wrapper to eliminate compiler warnings