--------------------- PatchSet 10386 Date: 2008/01/09 13:53:32 Author: adri Branch: s27_adri Tag: (none) Log: Move the buffer content relocation code out into clientReadRequest(). Members: src/client_side.c:1.202.2.9.4.26->1.202.2.9.4.27 Index: squid/src/client_side.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/client_side.c,v retrieving revision 1.202.2.9.4.26 retrieving revision 1.202.2.9.4.27 diff -u -r1.202.2.9.4.26 -r1.202.2.9.4.27 --- squid/src/client_side.c 9 Jan 2008 08:44:49 -0000 1.202.2.9.4.26 +++ squid/src/client_side.c 9 Jan 2008 13:53:32 -0000 1.202.2.9.4.27 @@ -1,6 +1,6 @@ /* - * $Id: client_side.c,v 1.202.2.9.4.26 2008/01/09 08:44:49 adri Exp $ + * $Id: client_side.c,v 1.202.2.9.4.27 2008/01/09 13:53:32 adri Exp $ * * DEBUG: section 33 Client-side Routines * AUTHOR: Duane Wessels @@ -3913,15 +3913,6 @@ request_t *request = NULL; HttpMsgBuf msg; - - /* Skip leading (and trailing) whitespace */ - while (conn->in.offset > 0 && xisspace(conn->in.buf[0])) { - xmemmove(conn->in.buf, conn->in.buf + 1, conn->in.offset - 1); - conn->in.offset--; - } - if (conn->in.offset == 0) - return 0; - HttpMsgBufInit(&msg, conn->in.buf, conn->in.offset); /* XXX for now there's no deallocation function needed but this may change */ /* Limit the number of concurrent requests to 2 */ for (n = conn->reqs.head, nrequests = 0; n; n = n->next, nrequests++); @@ -3978,16 +3969,13 @@ errorAppendEntry(http->entry, err); return -1; } - /* - * If we read past the end of this request, move the remaining - * data to the beginning - */ - assert(conn->in.offset >= http->req_sz); - conn->in.offset -= http->req_sz; - debug(33, 5) ("removing %d bytes; conn->in.offset = %d\n", (int) http->req_sz, (int) conn->in.offset); - if (conn->in.offset > 0) - xmemmove(conn->in.buf, conn->in.buf + http->req_sz, conn->in.offset); + /* + * XXX we used to pull the remainder bytes out here. Its possible that + * XXX the hdr_sz is right here but subsequently changes before we return. + * XXX Keep this in mind if Weird Stuff Happens. -adrian + */ + if (!http->flags.internal && internalCheck(strBuf2(request->urlpath), strLen2(request->urlpath))) { if (internalHostnameIs(request->host)) http->flags.internal = 1; @@ -4191,9 +4179,32 @@ ret = 0; while (cbdataValid(conn) && conn->in.offset > 0 && conn->body.size_left == 0) { /* Ret tells us how many bytes was consumed - 0 == didn't consume request, > 0 == consumed, -1 == error, -2 == CONNECT request stole the connection */ + + /* Skip leading (and trailing) whitespace */ + while (conn->in.offset > 0 && xisspace(conn->in.buf[0])) { + xmemmove(conn->in.buf, conn->in.buf + 1, conn->in.offset - 1); + conn->in.offset--; + } + if (conn->in.offset == 0) { + ret = 0; + break; + } + ret = clientTryParseRequest(conn); if (ret <= 0) break; + + /* + * If we read past the end of this request, move the remaining + * data to the beginning + */ + if (ret > 0) { + assert(conn->in.offset >= ret); + conn->in.offset -= ret; + debug(33, 5) ("clientReadRequest: FD %d: removing %d bytes; conn->in.offset = %d\n", fd, (int) ret, (int) conn->in.offset); + if (conn->in.offset > 0) + xmemmove(conn->in.buf, conn->in.buf + ret, conn->in.offset); + } } /* while offset > 0 && conn->body.size_left == 0 */ if (!cbdataValid(conn)) { cbdataUnlock(conn);