]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Fix/Add request-line parser debugging; fix bug with pipelined connection parsing
authoradrian <>
Mon, 2 Oct 2006 07:34:18 +0000 (07:34 +0000)
committeradrian <>
Mon, 2 Oct 2006 07:34:18 +0000 (07:34 +0000)
The unparsed request buffer was being relocated before the headers were being
parsed. That was fine - the request parsing used to happen with a copy of the
buffer - but now a copy isn't being made. The buffer relocation needed to be
changed to happen after the request was parsed.

src/HttpMsg.cc
src/HttpMsg.h
src/client_side.cc

index 478141c1610497497801e21a9e652dab04ea63b1..a3adbe0b8aec2537738600f22e5d0209b008e782 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: HttpMsg.cc,v 1.36 2006/10/01 17:27:10 adrian Exp $
+ * $Id: HttpMsg.cc,v 1.37 2006/10/02 01:34:18 adrian Exp $
  *
  * DEBUG: section 74    HTTP Message
  * AUTHOR: Alex Rousskov
@@ -399,6 +399,7 @@ HttpParserInit(HttpParser *hdr, const char *buf, int bufsiz)
        hdr->bufsiz = bufsiz;
        hdr->req_start = hdr->req_end = -1;
        hdr->hdr_start = hdr->hdr_end = -1;
+       debug(74, 5)("httpParseInit: Request buffer is %s\n", buf);
 }
 
 #if MSGDODEBUG
@@ -464,6 +465,8 @@ HttpParserParseReqLine(HttpParser *hmsg)
        int maj = -1, min = -1;
        int last_whitespace = -1, line_end = -1;
 
+       debug(74, 5)("httpParserParseReqLine: parsing %s\n", hmsg->buf);
+
        PROF_start(HttpParserParseReqLine);
        /* Find \r\n - end of URL+Version (and the request) */
        hmsg->req_end = -1;
@@ -481,7 +484,8 @@ HttpParserParseReqLine(HttpParser *hmsg)
                retcode = 0;
                goto finish;
        }
-       assert(hmsg->buf[hmsg->req_end] != '\n' && hmsg->buf[hmsg->req_end] != '\r');
+       assert(hmsg->buf[hmsg->req_end] != '\n');
+       assert(hmsg->buf[hmsg->req_end - 1] == '\n');
        /* Start at the beginning again */
        i = 0;
 
@@ -608,7 +612,7 @@ finish:
        assert(maj != -1);
        assert(min != -1);
        PROF_stop(HttpParserParseReqLine);
-       debug(1, 1) ("Parser: retval %d: from %d->%d: method %d->%d; url %d->%d; version %d->%d (%d/%d)\n",
+       debug(74, 5) ("Parser: retval %d: from %d->%d: method %d->%d; url %d->%d; version %d->%d (%d/%d)\n",
            retcode, hmsg->req_start, hmsg->req_end,
            hmsg->m_start, hmsg->m_end,
            hmsg->u_start, hmsg->u_end,
index 66495bacc5661e237eaf8cb1ae624ceea8ec72a9..efc6d64e710283833434708c6847b87994df018f 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: HttpMsg.h,v 1.13 2006/09/27 13:47:53 adrian Exp $
+ * $Id: HttpMsg.h,v 1.14 2006/10/02 01:34:18 adrian Exp $
  *
  *
  * SQUID Web Proxy Cache          http://www.squid-cache.org/
@@ -117,6 +117,7 @@ typedef struct _HttpParser HttpParser;
 extern void HttpParserInit(HttpParser *, const char *buf, int len);
 extern int HttpParserParseReqLine(HttpParser *hp);
 
+#define MSGDODEBUG 0
 #if MSGDODEBUG
 extern int HttpParserReqSz(HttpParser *);
 extern int HttpParserHdrSz(HttpParser *);
index 55d7245908d761c4938aba7aedbaddafdf7d657d..26715aaedae9dc9079eb8354ca72326c5acf1c1f 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: client_side.cc,v 1.740 2006/09/27 13:47:53 adrian Exp $
+ * $Id: client_side.cc,v 1.741 2006/10/02 01:34:18 adrian Exp $
  *
  * DEBUG: section 33    Client-side Routines
  * AUTHOR: Duane Wessels
@@ -2140,8 +2140,6 @@ clientProcessRequest(ConnStateData::Pointer &conn, HttpParser *hp, ClientSocketC
     HttpRequest *request = NULL;
     /* We have an initial client stream in place should it be needed */
     /* setup our private context */
-    connNoteUseOfBuffer(conn.getRaw(), http->req_sz);
-
     context->registerWithConn();
 
     if (context->flags.parsed_ok == 0) {
@@ -2154,7 +2152,7 @@ clientProcessRequest(ConnStateData::Pointer &conn, HttpParser *hp, ClientSocketC
         assert(context->http->out.offset == 0);
         context->pullData();
         conn->flags.readMoreRequests = false;
-        return;
+       goto finish;
     }
 
     if ((request = HttpRequest::CreateFromUrlAndMethod(http->uri, method)) == NULL) {
@@ -2168,7 +2166,7 @@ clientProcessRequest(ConnStateData::Pointer &conn, HttpParser *hp, ClientSocketC
         assert(context->http->out.offset == 0);
         context->pullData();
         conn->flags.readMoreRequests = false;
-        return;
+       goto finish;
     }
 
     /* compile headers */
@@ -2185,7 +2183,7 @@ clientProcessRequest(ConnStateData::Pointer &conn, HttpParser *hp, ClientSocketC
         assert(context->http->out.offset == 0);
         context->pullData();
         conn->flags.readMoreRequests = false;
-        return;
+       goto finish;
     }
 
     request->flags.accelerated = http->flags.accel;
@@ -2228,7 +2226,7 @@ clientProcessRequest(ConnStateData::Pointer &conn, HttpParser *hp, ClientSocketC
         assert(context->http->out.offset == 0);
         context->pullData();
         conn->flags.readMoreRequests = false;
-        return;
+       goto finish;
     }
 
 
@@ -2242,7 +2240,7 @@ clientProcessRequest(ConnStateData::Pointer &conn, HttpParser *hp, ClientSocketC
         assert(context->http->out.offset == 0);
         context->pullData();
         conn->flags.readMoreRequests = false;
-        return;
+       goto finish;
     }
 
     http->request = HTTPMSGLOCK(request);
@@ -2274,7 +2272,7 @@ clientProcessRequest(ConnStateData::Pointer &conn, HttpParser *hp, ClientSocketC
             assert(context->http->out.offset == 0);
             context->pullData();
             conn->flags.readMoreRequests = false;
-            return;
+           goto finish;
         }
 
         context->mayUseConnection(true);
@@ -2287,6 +2285,10 @@ clientProcessRequest(ConnStateData::Pointer &conn, HttpParser *hp, ClientSocketC
     http->calloutContext = new ClientRequestContext(http);
 
     http->doCallouts();
+
+finish:
+    /* Consume request buffer */
+    connNoteUseOfBuffer(conn.getRaw(), http->req_sz);
 }
 
 static void