]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Convert HttpParser to dynamic reference counted class
authorAmos Jeffries <squid3@treenet.co.nz>
Fri, 1 Nov 2013 15:32:58 +0000 (08:32 -0700)
committerAmos Jeffries <squid3@treenet.co.nz>
Fri, 1 Nov 2013 15:32:58 +0000 (08:32 -0700)
This creates a dedicated HttpParser object for each new request in
preparation for incremental parsing of the client connection buffer.

NP: incremental parse is not yet done so when requests require multiple
  calls of the parse routine it will for now generate a new parser state
  object and discard the previous partial parse details.

src/HttpParser.h
src/client_side.cc
src/client_side.h

index 7e941528dbea23ff4e1b61fc66465ee86e8e4100..af3d899042f885ae51bb1e3841e01acfcbddcffb 100644 (file)
@@ -1,6 +1,7 @@
 #ifndef _SQUID_SRC_HTTPPARSER_H
 #define _SQUID_SRC_HTTPPARSER_H
 
+#include "base/RefCount.h"
 #include "http/StatusCode.h"
 
 // Parser states
  * \item Request Line (method, URL, protocol, version)
  * \item Mime header block
  */
-class HttpParser
+class HttpParser : public RefCountable
 {
 public:
+    typedef RefCount<HttpParser> Pointer;
+
     HttpParser() { clear(); }
 
     /** Initialize a new parser.
@@ -78,7 +81,6 @@ public:
 };
 
 // Legacy functions
-#define HttpParserInit(h,b,l) (h)->reset((b),(l))
 int HttpParserParseReqLine(HttpParser *hp);
 
 #define MSGDODEBUG 0
index 1f402207b76a6552848d8e1861bd373cfe7a39f6..e25e7b093c1c37d21da471ee5886377d4df9f492 100644 (file)
@@ -2991,11 +2991,11 @@ ConnStateData::clientParseRequests()
 
         /* Begin the parsing */
         PROF_start(parseHttpRequest);
-        HttpParserInit(&parser_, in.buf, in.notYetUsed);
+        parser_ = new HttpParser(in.buf, in.notYetUsed);
 
         /* Process request */
         Http::ProtocolVersion http_ver;
-        ClientSocketContext *context = parseHttpRequest(this, &parser_, &method, &http_ver);
+        ClientSocketContext *context = parseHttpRequest(this, parser_.getRaw(), &method, &http_ver);
         PROF_stop(parseHttpRequest);
 
         /* partial or incomplete request */
@@ -3013,7 +3013,7 @@ ConnStateData::clientParseRequests()
                                              CommTimeoutCbPtrFun(clientLifetimeTimeout, context->http));
             commSetConnTimeout(clientConnection, Config.Timeout.lifetime, timeoutCall);
 
-            clientProcessRequest(this, &parser_, context, method, http_ver);
+            clientProcessRequest(this, parser_.getRaw(), context, method, http_ver);
 
             parsed_req = true; // XXX: do we really need to parse everything right NOW ?
 
index ec95d11cc5874050c3c51a0cf7322635715867df..0117f2b8b6f37664f87f6fcf2ee6a15ea730442d 100644 (file)
@@ -398,7 +398,7 @@ private:
     Auth::UserRequest::Pointer auth_;
 #endif
 
-    HttpParser parser_;
+    HttpParser::Pointer parser_;
 
     // XXX: CBDATA plays with public/private and leaves the following 'private' fields all public... :(