--------------------- PatchSet 10343 Date: 2007/12/29 09:08:23 Author: adri Branch: s27_adri Tag: (none) Log: change httpAppendBody() to take (buf, len), offset like the changes to the header parser block, this will make it easier to migrate the code to use buf_t soon. Members: src/http.c:1.63.2.3.4.25->1.63.2.3.4.26 Index: squid/src/http.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/http.c,v retrieving revision 1.63.2.3.4.25 retrieving revision 1.63.2.3.4.26 diff -u -r1.63.2.3.4.25 -r1.63.2.3.4.26 --- squid/src/http.c 28 Dec 2007 06:46:54 -0000 1.63.2.3.4.25 +++ squid/src/http.c 29 Dec 2007 09:08:23 -0000 1.63.2.3.4.26 @@ -1,6 +1,6 @@ /* - * $Id: http.c,v 1.63.2.3.4.25 2007/12/28 06:46:54 adri Exp $ + * $Id: http.c,v 1.63.2.3.4.26 2007/12/29 09:08:23 adri Exp $ * * DEBUG: section 11 Hypertext Transfer Protocol (HTTP) * AUTHOR: Harvest Derived @@ -643,8 +643,19 @@ return rc; } +/* + * Append some body data. sbuf/slen are the buffer and buffer length; + * offset is the offset in the buffer where the body starts. + * So the amount of data is actually slen - offset. + * + * buffer_filled is an indication whether the previous read() filled the + * read buffer or not. The original code set the read buffer to the + * system read buffer size so I think it assumed if the buffer was filled + * then there may be more data available; if the buffer wasn't filled + * then there wasn't any more data available.. + */ static void -httpAppendBody(HttpStateData * httpState, const char *buf, ssize_t len, int buffer_filled) +httpAppendBody(HttpStateData * httpState, const char *sbuf, ssize_t slen, int offset, int buffer_filled) { StoreEntry *entry = httpState->entry; const request_t *request = httpState->request; @@ -654,6 +665,9 @@ int fd = httpState->fd; int complete = httpState->eof; int keep_alive = !httpState->eof; + const char *buf = sbuf + offset; + ssize_t len = slen - offset; + assert(len >= 0); storeBuffer(entry); while (len > 0) { if (httpState->chunk_size > 0) { @@ -758,7 +772,7 @@ } /* Is it a incomplete reply? */ if (httpState->chunk_size > 0) { - debug(11, 2) ("Short response from '%s' on port %d. Expecting %" PRINTF_OFF_T " octets more\n", storeUrl(entry), comm_local_port(fd), httpState->chunk_size); + debug(11, 1) ("Short response from '%s' on port %d. Expecting %" PRINTF_OFF_T " octets more\n", storeUrl(entry), comm_local_port(fd), httpState->chunk_size); comm_close(fd); return; } @@ -954,7 +968,7 @@ fwdFail(httpState->fwd, errorCon(ERR_INVALID_RESP, HTTP_BAD_GATEWAY, httpState->fwd->request)); httpState->fwd->flags.dont_retry = 1; } else { - httpAppendBody(httpState, NULL, 0, -1); /* EOF */ + httpAppendBody(httpState, NULL, 0, 0, -1); /* EOF */ return; } comm_close(fd); @@ -1017,7 +1031,7 @@ assert(! memBufIsNull(&httpState->reply_hdr)); assert(buf_start - done < httpState->reply_hdr.size); cbdataLock(httpState); - httpAppendBody(httpState, httpState->reply_hdr.buf + done + buf_start, httpState->reply_hdr.size - done - buf_start, buffer_filled); + httpAppendBody(httpState, httpState->reply_hdr.buf, httpState->reply_hdr.size, done + buf_start, buffer_filled); if (cbdataValid(httpState) && (! memBufIsNull(&httpState->reply_hdr))) memBufReset(&httpState->reply_hdr); cbdataUnlock(httpState);