--------------------- PatchSet 1477 Date: 2001/02/01 23:13:14 Author: rbcollins Branch: rbcollins_filters Tag: (none) Log: bugfixes and tidyup. Bugfix in textreplace filter: wasn't filtering out the EOF flag for partial writes Members: src/http.c:1.1.1.3.4.1.4.12.2.6->1.1.1.3.4.1.4.12.2.7 src/transfer-encoding.c:1.1.2.1.2.3->1.1.2.1.2.4 src/modules/textreplace/textreplace.c:1.1.2.5->1.1.2.6 Index: squid/src/http.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/http.c,v retrieving revision 1.1.1.3.4.1.4.12.2.6 retrieving revision 1.1.1.3.4.1.4.12.2.7 diff -u -r1.1.1.3.4.1.4.12.2.6 -r1.1.1.3.4.1.4.12.2.7 --- squid/src/http.c 1 Feb 2001 13:37:48 -0000 1.1.1.3.4.1.4.12.2.6 +++ squid/src/http.c 1 Feb 2001 23:13:14 -0000 1.1.1.3.4.1.4.12.2.7 @@ -1,6 +1,6 @@ /* - * $Id: http.c,v 1.1.1.3.4.1.4.12.2.6 2001/02/01 13:37:48 rbcollins Exp $ + * $Id: http.c,v 1.1.1.3.4.1.4.12.2.7 2001/02/01 23:13:14 rbcollins Exp $ * * DEBUG: section 11 Hypertext Transfer Protocol (HTTP) * AUTHOR: Harvest Derived @@ -347,6 +347,7 @@ if (0 == k) return; /* headers not complete */ t = httpState->reply_hdr + k; + httpState->headerlength=k; } *t = '\0'; httpState->reply_hdr_state++; @@ -585,8 +586,7 @@ StoreEntry *entry = httpState->entry; const request_t *request = httpState->request; FILTER_list *temp_filter; - debug(1,1)("Processing data\n"); - { + debug(1,1)("Processing data (len=%d\n",len); if (httpState->reply_hdr_state < 2) { /* we haven't seen the full headers yet */ /* ProcessReplyHeader expects partial data. This can be cleaned up now */ @@ -632,60 +632,42 @@ if (httpState->headerstore && httpState->reply_hdr_state == 2) { /* headers have been processed, but there's a last combine step to do */ char *tempbuf; + size_t hdr_len; tempbuf=httpState->headerstore; httpState->headerstore=xmalloc(httpState->headerlength+len); memcpy(httpState->headerstore,tempbuf,httpState->headerlength); memcpy(httpState->headerstore+httpState->headerlength,buf,len); httpState->headerlength+=len; xfree(tempbuf); -debug(1,1)("sending combined headers\n"); - assert(httpState->filters.head); - temp_filter=httpState->filters.head->data; - temp_filter->filter(httpState->headerstore, httpState->headerlength, &httpState->filters, temp_filter, FILTER_HTTP_HEADER, temp_filter->data); -#if 0 - temp_filter=filters->node.next->data; - temp_filter->filter(httpState->headerstore,httpState->headerlength,filter_list, temp_filter, flags, temp_filter->data); - xfree(httpState->headerstore); - httpState->headerstore=NULL; - httpState->headerlength=0; - dlinkDelete(&filters->node, filter_list); - /* if I alloced data for _me_ free it */ - /* free the list entry */ - xfree(filters); -#endif - + hdr_len=httpState->headerlength; + debug(1,1)("sending combined headers\n"); + assert(httpState->filters.head); + temp_filter=httpState->filters.head->data; + temp_filter->filter(httpState->headerstore, hdr_len, &httpState->filters, temp_filter, FILTER_HTTP_HEADER, temp_filter->data); } else if (httpState->reply_hdr_state == 2){ - /* no partial headers, got them in one chunk */ -debug(1,1)("headers in one packet... sending\n"); - assert(httpState->filters.head); - temp_filter=httpState->filters.head->data; - temp_filter->filter(buf, len, &httpState->filters, temp_filter, FILTER_HTTP_HEADER, temp_filter->data); -debug(1,1)("headers written \n"); -#if 0 - { - FILTER_list *temp; - temp=filters->prev; - filters->prev=filters->prev->prev; - if (temp->prev) - temp->prev->next=filters; - /* if I alloced data for _me_ free it */ - /* free the list entry */ - xfree(temp); - } - /* if I alloced data for _me_ free it */ - /* free the list entry */ - dlinkDelete(&filters->node, filter_list); - xfree(filters); -#endif + size_t hdr_len=httpState->headerlength; + /* no partial headers, got them in one chunk */ + debug(1,1)("headers in one packet... sending %d bytes\n", + hdr_len); + assert(httpState->filters.head); + temp_filter=httpState->filters.head->data; + temp_filter->filter(buf, hdr_len, + &httpState->filters, temp_filter, FILTER_HTTP_HEADER, + temp_filter->data); + debug(1,1)("headers (%d bytes) written, sending body (%d of %d)\n", + hdr_len, + len-hdr_len,len); + if (len-hdr_len) + temp_filter->filter(buf+hdr_len,len-hdr_len, &httpState->filters, temp_filter, 0, temp_filter->data); } } else { /* headers have been seen. */ + debug(1,1)("headers previously written \n"); assert(httpState->filters.head); temp_filter=httpState->filters.head->data; temp_filter->filter(buf, len, &httpState->filters, temp_filter, 0, temp_filter->data); } - } } # if 0 void httpPerformTE(const char *buf, size_t len, dlink_list *filter_list, FILTER_list *filters, unsigned int flags, void *data) Index: squid/src/transfer-encoding.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/Attic/transfer-encoding.c,v retrieving revision 1.1.2.1.2.3 retrieving revision 1.1.2.1.2.4 diff -u -r1.1.2.1.2.3 -r1.1.2.1.2.4 --- squid/src/transfer-encoding.c 1 Feb 2001 13:37:48 -0000 1.1.2.1.2.3 +++ squid/src/transfer-encoding.c 1 Feb 2001 23:13:14 -0000 1.1.2.1.2.4 @@ -306,7 +306,7 @@ return; } - debug (33,8)("undochunked: skipping header block\n"); + debug (33,8)("undochunked: sending unchunked data, len %d flags %d\n",created, flags | newflags); temp_filter->filter(tb,created,filter_list, temp_filter, flags | newflags, temp_filter->data); } Index: squid/src/modules/textreplace/textreplace.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/modules/textreplace/Attic/textreplace.c,v retrieving revision 1.1.2.5 retrieving revision 1.1.2.6 diff -u -r1.1.2.5 -r1.1.2.6 --- squid/src/modules/textreplace/textreplace.c 31 Jan 2001 12:41:53 -0000 1.1.2.5 +++ squid/src/modules/textreplace/textreplace.c 1 Feb 2001 23:13:14 -0000 1.1.2.6 @@ -1,6 +1,6 @@ /* - * $Id: textreplace.c,v 1.1.2.5 2001/01/31 12:41:53 rbcollins Exp $ + * $Id: textreplace.c,v 1.1.2.6 2001/02/01 23:13:14 rbcollins Exp $ * * DEBUG: section 83 Content Processing Filters * AUTHOR: Robert Collins @@ -252,11 +252,11 @@ /* send the first set of data */ if (startpos - lastmatch) temp_filter->filter (lastmatch, startpos - lastmatch, - filter_list, temp_filter, flags, + filter_list, temp_filter, flags & !FILTER_EOF, temp_filter->data); /* send the filter set of data */ temp_filter->filter (config->replace, replacelen, - filter_list, temp_filter, flags, + filter_list, temp_filter, flags & !FILTER_EOF, temp_filter->data); lastmatch = startpos + searchlen; /* update the pointers */