--------------------- PatchSet 10345 Date: 2007/12/29 13:36:05 Author: adri Branch: s27_adri Tag: (none) Log: Convert httpAppendBody() to take a buf_t rather than (const char *, len). Members: src/http.c:1.63.2.3.4.27->1.63.2.3.4.28 Index: squid/src/http.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/http.c,v retrieving revision 1.63.2.3.4.27 retrieving revision 1.63.2.3.4.28 diff -u -r1.63.2.3.4.27 -r1.63.2.3.4.28 --- squid/src/http.c 29 Dec 2007 10:57:49 -0000 1.63.2.3.4.27 +++ squid/src/http.c 29 Dec 2007 13:36:05 -0000 1.63.2.3.4.28 @@ -1,6 +1,6 @@ /* - * $Id: http.c,v 1.63.2.3.4.27 2007/12/29 10:57:49 adri Exp $ + * $Id: http.c,v 1.63.2.3.4.28 2007/12/29 13:36:05 adri Exp $ * * DEBUG: section 11 Hypertext Transfer Protocol (HTTP) * AUTHOR: Harvest Derived @@ -656,7 +656,7 @@ * then there wasn't any more data available.. */ static void -httpAppendBody(HttpStateData * httpState, const char *sbuf, ssize_t slen, int offset, int buffer_filled) +httpAppendBody(HttpStateData * httpState, buf_t *b, int offset, int buffer_filled) { StoreEntry *entry = httpState->entry; const request_t *request = httpState->request; @@ -666,8 +666,15 @@ int fd = httpState->fd; int complete = httpState->eof; int keep_alive = !httpState->eof; - const char *buf = sbuf + offset; - ssize_t len = slen - offset; + + const char *buf = NULL; + ssize_t len = 0; + + if (b) { + buf = buf_buf(b) + offset; + len = buf_len(b) - offset; + } + assert(len >= 0); storeBuffer(entry); debug(11, 2) ("httpAppendBody: FD %d: given %d bytes to look at\n", httpState->fd, (int) len); @@ -976,7 +983,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, 0, -1); /* EOF */ + httpAppendBody(httpState, NULL, 0, -1); /* EOF */ return; } comm_close(fd); @@ -1040,7 +1047,7 @@ assert(httpState->replybuf); assert(buf_start - done < buf_len(httpState->replybuf)); cbdataLock(httpState); - httpAppendBody(httpState, buf_buf(httpState->replybuf), buf_len(httpState->replybuf), done + buf_start, buffer_filled); + httpAppendBody(httpState, httpState->replybuf, done + buf_start, buffer_filled); if (cbdataValid(httpState) && httpState->replybuf) httpState->replybuf = buf_deref(httpState->replybuf); cbdataUnlock(httpState);