--------------------- PatchSet 10320 Date: 2007/12/27 10:04:47 Author: adri Branch: s27_adri Tag: (none) Log: Add a "beginning" pointer so we can do things like skip the whitespace in the request without memmove()'ing. eventually this parameter should be passed into the parser block and body append block functions, as they should receive a MemBuf + offset rather than a buf + size. Members: src/http.c:1.63.2.3.4.21->1.63.2.3.4.22 Index: squid/src/http.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/http.c,v retrieving revision 1.63.2.3.4.21 retrieving revision 1.63.2.3.4.22 diff -u -r1.63.2.3.4.21 -r1.63.2.3.4.22 --- squid/src/http.c 27 Dec 2007 05:12:20 -0000 1.63.2.3.4.21 +++ squid/src/http.c 27 Dec 2007 10:04:47 -0000 1.63.2.3.4.22 @@ -1,6 +1,6 @@ /* - * $Id: http.c,v 1.63.2.3.4.21 2007/12/27 05:12:20 adri Exp $ + * $Id: http.c,v 1.63.2.3.4.22 2007/12/27 10:04:47 adri Exp $ * * DEBUG: section 11 Hypertext Transfer Protocol (HTTP) * AUTHOR: Harvest Derived @@ -859,6 +859,8 @@ #endif int buffer_filled; + int buf_start = 0; /* Starting point of the buffer to pass to "stuff" */ + if (EBIT_TEST(entry->flags, ENTRY_ABORTED)) { comm_close(fd); return; @@ -896,8 +898,10 @@ if (!httpState->reply_hdr.size && len > 0 && fd_table[fd].uses > 1) { /* Skip whitespace */ /* XXX must redo this later once we're using buf's and offset pointers, not MemBuf's */ - //while (len > 0 && xisspace(*buf)) - // xmemmove(buf, buf + 1, len--); + while (len > 0 && xisspace(*(httpState->reply_hdr.buf + buf_start))) { + buf_start++; + len--; + } if (len == 0) { /* Continue to read... */ /* Timeout NOT increased. This whitespace was from previous reply */ @@ -933,7 +937,8 @@ */ /* Fake an "end-of-headers" to work around such broken servers */ memBufAppend(&httpState->reply_hdr, "\r\n", 2); - httpProcessReplyHeaderBlock(httpState, httpState->reply_hdr.buf, httpState->reply_hdr.size); + assert(buf_start < httpState->reply_hdr.size); + httpProcessReplyHeaderBlock(httpState, httpState->reply_hdr.buf + buf_start, httpState->reply_hdr.size - buf_start); } if (entry->mem_obj->reply->sline.status == HTTP_HEADER_TOO_LARGE) { storeEntryReset(entry); @@ -956,7 +961,8 @@ * httpAppendBody(). */ storeBuffer(entry); - done = httpProcessReplyHeaderBlock(httpState, httpState->reply_hdr.buf, httpState->reply_hdr.size); + assert(buf_start < httpState->reply_hdr.size); + done = httpProcessReplyHeaderBlock(httpState, httpState->reply_hdr.buf + buf_start, httpState->reply_hdr.size - buf_start); if (httpState->reply_hdr_state == 2) { http_status s = entry->mem_obj->reply->sline.status; if (s == HTTP_HEADER_TOO_LARGE) { @@ -982,7 +988,8 @@ httpHeaderPutTime(&reply->header, HDR_DATE, squid_curtime); mb = httpReplyPack(reply); storeAppend(entry, mb.buf, mb.size); - storeAppend(entry, httpState->reply_hdr.buf, httpState->reply_hdr.size); + assert(buf_start < httpState->reply_hdr.size); + storeAppend(entry, httpState->reply_hdr.buf + buf_start, httpState->reply_hdr.size - buf_start); httpReplyReset(reply); httpReplyParse(reply, mb.buf, mb.size); memBufClean(&mb); @@ -1003,7 +1010,8 @@ } } assert(! memBufIsNull(&httpState->reply_hdr)); - httpAppendBody(httpState, httpState->reply_hdr.buf + done, httpState->reply_hdr.size - done, buffer_filled); + assert(buf_start - done < httpState->reply_hdr.size); + httpAppendBody(httpState, httpState->reply_hdr.buf + done + buf_start, httpState->reply_hdr.size - done - buf_start, buffer_filled); if (! memBufIsNull(&httpState->reply_hdr)) memBufReset(&httpState->reply_hdr); return;