From: Amos Jeffries Date: Fri, 1 Nov 2013 15:32:58 +0000 (-0700) Subject: Convert HttpParser to dynamic reference counted class X-Git-Tag: merge-candidate-3-v1~506^2~114 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=25f0d354d075dc7bbd4559fbaa948f5daa26b643;p=thirdparty%2Fsquid.git Convert HttpParser to dynamic reference counted class 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. --- diff --git a/src/HttpParser.h b/src/HttpParser.h index 7e941528db..af3d899042 100644 --- a/src/HttpParser.h +++ b/src/HttpParser.h @@ -1,6 +1,7 @@ #ifndef _SQUID_SRC_HTTPPARSER_H #define _SQUID_SRC_HTTPPARSER_H +#include "base/RefCount.h" #include "http/StatusCode.h" // Parser states @@ -15,9 +16,11 @@ * \item Request Line (method, URL, protocol, version) * \item Mime header block */ -class HttpParser +class HttpParser : public RefCountable { public: + typedef RefCount 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 diff --git a/src/client_side.cc b/src/client_side.cc index 1f402207b7..e25e7b093c 100644 --- a/src/client_side.cc +++ b/src/client_side.cc @@ -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 ? diff --git a/src/client_side.h b/src/client_side.h index ec95d11cc5..0117f2b8b6 100644 --- a/src/client_side.h +++ b/src/client_side.h @@ -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... :(