--------------------- PatchSet 2229 Date: 2001/05/07 11:46:03 Author: rbcollins Branch: newhttp Tag: (none) Log: working initial code Members: src/http.c:1.1.1.3.4.1.4.12.2.16.2.6->1.1.1.3.4.1.4.12.2.16.2.7 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.16.2.6 retrieving revision 1.1.1.3.4.1.4.12.2.16.2.7 diff -u -r1.1.1.3.4.1.4.12.2.16.2.6 -r1.1.1.3.4.1.4.12.2.16.2.7 --- squid/src/http.c 4 May 2001 14:39:35 -0000 1.1.1.3.4.1.4.12.2.16.2.6 +++ squid/src/http.c 7 May 2001 11:46:03 -0000 1.1.1.3.4.1.4.12.2.16.2.7 @@ -1,6 +1,6 @@ /* - * $Id: http.c,v 1.1.1.3.4.1.4.12.2.16.2.6 2001/05/04 14:39:35 rbcollins Exp $ + * $Id: http.c,v 1.1.1.3.4.1.4.12.2.16.2.7 2001/05/07 11:46:03 rbcollins Exp $ * * DEBUG: section 11 Hypertext Transfer Protocol (HTTP) * AUTHOR: Harvest Derived @@ -1363,7 +1363,7 @@ * request. Later on we can look at different read callbacks for in progress requests */ static void -httpCommReadComplete(int fd, char *buf, off_t offset, size_t size, int howmuch, int flag, +httpCommReadComplete(int fd, char *buf, off_t offset, size_t size, int howmuch, int flags, void *data) { HttpStateData *http=data; @@ -1379,7 +1379,7 @@ buf = the buffer data or possibly, move size into buf... */ - if (http->rep) { + if (http->rep && http->hcrequest->repfilters.head) { /* possibly just a case of call the filter chain... */ FILTER_list *temp_filter; unsigned int rvflags, eofflag; @@ -1388,13 +1388,29 @@ assert(offset==0); temp_filter=http->hcrequest->repfilters.head->data; http->read_offset+=howmuch; + /* check for trivial EOF status. */ + #define COMM_EOF 0 + eofflag = ((http->read_offset >= http->rep->content_length) || (flags & COMM_EOF)) ? FILTER_EOF : 0; + debug (33,0)("read offset is %d, content length %d\n",http->read_offset, http->rep->content_length); + /* FIXME: check for content overrun here */ + /* NOTE: however we do this, it must be callable by the TE code as well.. */ /* Allow a new read to be scheduled */ readbuf=http->readbuf; http->readbuf=NULL; - rvflags=temp_filter->filter(readbuf->buffer,howmuch,http->read_offset-howmuch,&http->hcrequest->repfilters, temp_filter,0,temp_filter->data); + /* if this looks hacky.. it is. comm_reads not finished, and these two code + * blocks are reversed */ + rvflags=temp_filter->filter(howmuch ? readbuf->buffer : NULL, + howmuch,http->read_offset-howmuch, + &http->hcrequest->repfilters, temp_filter,eofflag,temp_filter->data); cbdataUnlock(readbuf); /* TODO: one of the filters needs to be a pipeline request handler that gets the next request handled correctly - setups this func up again */ debug (33,3)("Process request got flags %0x from rep_filter\n", rvflags); + /* TODO: cancel the read in some fashion if EOF is signalled after a read is queued */ + if (rvflags & FILTER_EOF || eofflag) { + http->hcrequest->serverread=NULL; + http->hcrequest->serverreaddata=NULL; + cbdataUnlock(http); + } return; } @@ -1413,7 +1429,10 @@ http->read_offset=0; /* FIXME: this is broken if the server writes the headers in a different *packet to the first body data: we need to check the status line */ - eofflag = !(http->readbuf->offset - headerlen) ? FILTER_EOF : 0; + if (!http->rep->content_length) + eofflag = !(http->readbuf->offset - headerlen) ? FILTER_EOF : 0; + else + eofflag = 0; /* Allow a new read to be scheduled */ readbuf=http->readbuf; http->readbuf=NULL; @@ -1422,6 +1441,7 @@ if ((readbuf->offset-headerlen) && !(rvflags & (FILTER_ABORT | FILTER_EOF))) { temp_filter=http->hcrequest->repfilters.head->data; + http->read_offset+=readbuf->offset-headerlen; /* offset total length in buffer */ rvflags=temp_filter->filter(readbuf->buffer+readbuf->offset+headerlen-howmuch,readbuf->offset-headerlen,0,&http->hcrequest->repfilters, temp_filter,0,temp_filter->data);