]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Create "inlined" Macro versions of the offset functions with the new request parser
authoradrian <>
Wed, 27 Sep 2006 19:47:53 +0000 (19:47 +0000)
committeradrian <>
Wed, 27 Sep 2006 19:47:53 +0000 (19:47 +0000)
src/HttpMsg.cc
src/HttpMsg.h
src/client_side.cc

index 6411b1aa30ac2983933071b8dfcaa2fc4e3c2791..7870d1262dbb52f721ceaf06b636e0907ae91345 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: HttpMsg.cc,v 1.34 2006/09/27 13:17:52 adrian Exp $
+ * $Id: HttpMsg.cc,v 1.35 2006/09/27 13:47:53 adrian Exp $
  *
  * DEBUG: section 74    HTTP Message
  * AUTHOR: Alex Rousskov
@@ -401,6 +401,7 @@ HttpParserInit(HttpParser *hdr, const char *buf, int bufsiz)
        hdr->hdr_start = hdr->hdr_end = -1;
 }
 
+#if MSGDODEBUG
 /* XXX This should eventually turn into something inlined or #define'd */
 int
 HttpParserReqSz(HttpParser *hp)
@@ -440,6 +441,7 @@ HttpParserRequestLen(HttpParser *hp)
 {
        return hp->hdr_end - hp->req_start + 1;
 }
+#endif
 
 /*
  * Attempt to parse the request line.
@@ -462,6 +464,7 @@ HttpParserParseReqLine(HttpParser *hmsg)
        int maj = -1, min = -1;
        int last_whitespace = -1, line_end = -1;
 
+       PROF_start(HttpParserParseReqLine);
        /* Find \r\n - end of URL+Version (and the request) */
        for (i = 0; i < hmsg->bufsiz; i++) {
                if (hmsg->buf[i] == '\n') {
@@ -602,6 +605,7 @@ finish:
        hmsg->v_min = min;
        assert(maj != -1);
        assert(min != -1);
+       PROF_stop(HttpParserParseReqLine);
        debug(1, 2) ("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,
index 9818b8e112a70516349ec93060fec39c2c6c3f10..66495bacc5661e237eaf8cb1ae624ceea8ec72a9 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: HttpMsg.h,v 1.12 2006/09/27 13:17:52 adrian Exp $
+ * $Id: HttpMsg.h,v 1.13 2006/09/27 13:47:53 adrian Exp $
  *
  *
  * SQUID Web Proxy Cache          http://www.squid-cache.org/
@@ -115,11 +115,19 @@ struct _HttpParser {
 typedef struct _HttpParser HttpParser;
 
 extern void HttpParserInit(HttpParser *, const char *buf, int len);
+extern int HttpParserParseReqLine(HttpParser *hp);
+
+#if MSGDODEBUG
 extern int HttpParserReqSz(HttpParser *);
 extern int HttpParserHdrSz(HttpParser *);
 extern const char * HttpParserHdrBuf(HttpParser *);
 extern int HttpParserRequestLen(HttpParser *hp);
-extern int HttpParserParseReqLine(HttpParser *hp);
+#else
+#define        HttpParserReqSz(hp)     ( (hp)->req_end - (hp)->req_start + 1 )
+#define        HttpParserHdrSz(hp)     ( (hp)->hdr_end - (hp)->hdr_start + 1 )
+#define        HttpParserHdrBuf(hp)    ( (hp)->buf + (hp)->hdr_start )
+#define        HttpParserRequestLen(hp)        ( (hp)->hdr_end - (hp)->req_start + 1 )
+#endif
 
 SQUIDCEXTERN int httpMsgIsolateHeaders(const char **parse_start, int len, const char **blk_start, const char **blk_end);
 
index 0b03a7034ab2fa2cb8d2ac78a53fdd587937da79..55d7245908d761c4938aba7aedbaddafdf7d657d 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: client_side.cc,v 1.739 2006/09/27 13:17:52 adrian Exp $
+ * $Id: client_side.cc,v 1.740 2006/09/27 13:47:53 adrian Exp $
  *
  * DEBUG: section 33    Client-side Routines
  * AUTHOR: Duane Wessels
@@ -1865,6 +1865,7 @@ parseHttpRequest(ConnStateData::Pointer & conn, HttpParser *hp, method_t * metho
     /* Request line is valid here .. */
     *http_ver = HttpVersion(hp->v_maj, hp->v_min);
 
+    /* This call scans the entire request, not just the headers */
     if (hp->v_maj > 0) {
         if ((req_sz = headersEnd(hp->buf, hp->bufsiz)) == 0) {
             debug(33, 5) ("Incomplete request, waiting for end of headers\n");
@@ -1875,6 +1876,8 @@ parseHttpRequest(ConnStateData::Pointer & conn, HttpParser *hp, method_t * metho
         req_sz = HttpParserReqSz(hp);
     }
 
+    /* We know the whole request is in hp->buf now */
+
     assert(req_sz <= (size_t) hp->bufsiz);
     /* Will the following be true with HTTP/0.9 requests? probably not .. */
     /* So the rest of the code will need to deal with '0'-byte headers (ie, none, so don't try parsing em) */
@@ -1912,11 +1915,8 @@ parseHttpRequest(ConnStateData::Pointer & conn, HttpParser *hp, method_t * metho
      */
     /* XXX this code should be modified to take a const char * later! */
     req_hdr = (char *) hp->buf + hp->req_end + 1;
-
     debug(33, 3) ("parseHttpRequest: req_hdr = {%s}\n", req_hdr);
-
-    end = req_hdr + HttpParserHdrSz(hp);
-
+    end = (char *) hp->buf + hp->hdr_end;
     debug(33, 3) ("parseHttpRequest: end = {%s}\n", end);
 
     if (strstr(req_hdr, "\r\r\n")) {
@@ -1928,23 +1928,16 @@ parseHttpRequest(ConnStateData::Pointer & conn, HttpParser *hp, method_t * metho
     debug(33, 3) ("parseHttpRequest: prefix_sz = %d, req_line_sz = %d\n",
                   (int) HttpParserRequestLen(hp), HttpParserReqSz(hp));
 
-    assert((size_t) HttpParserRequestLen(hp) <= (size_t) hp->bufsiz);
-
     /* Ok, all headers are received */
     http = new ClientHttpRequest(conn);
 
     http->req_sz = HttpParserRequestLen(hp);
-
     result = ClientSocketContextNew(http);
-
     tempBuffer.data = result->reqbuf;
-
     tempBuffer.length = HTTP_REQBUF_SZ;
 
     ClientStreamData newServer = new clientReplyContext(http);
-
     ClientStreamData newClient = result;
-
     clientStreamInit(&http->client_stream, clientGetMoreData, clientReplyDetach,
                      clientReplyStatus, newServer, clientSocketRecipient,
                      clientSocketDetach, newClient, tempBuffer);