From: Amos Jeffries Date: Mon, 23 Dec 2013 12:16:33 +0000 (-0800) Subject: Rename HttpParser as Http::Http1Parser X-Git-Tag: merge-candidate-3-v1~506^2~86 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bb86dcd429b535fb94481db27cd9b386160c1128;p=thirdparty%2Fsquid.git Rename HttpParser as Http::Http1Parser --- diff --git a/src/Makefile.am b/src/Makefile.am index 87f1fcc414..5c7f248eff 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1066,7 +1066,7 @@ check_PROGRAMS+=\ tests/testEvent \ tests/testEventLoop \ tests/test_http_range \ - tests/testHttpParser \ + tests/testHttp1Parser \ tests/testHttpReply \ tests/testHttpRequest \ tests/testStore \ @@ -2521,7 +2521,7 @@ tests_test_http_range_LDFLAGS = $(LIBADD_DL) tests_test_http_range_DEPENDENCIES = \ $(SQUID_CPPUNIT_LA) -tests_testHttpParser_SOURCES = \ +tests_testHttp1Parser_SOURCES = \ Debug.h \ MemBuf.cc \ MemBuf.h \ @@ -2539,15 +2539,15 @@ tests_testHttpParser_SOURCES = \ tests/stub_HelperChildConfig.cc \ tools.h \ tests/stub_tools.cc \ - tests/testHttpParser.cc \ - tests/testHttpParser.h \ + tests/testHttp1Parser.cc \ + tests/testHttp1Parser.h \ tests/testMain.cc \ tests/stub_time.cc \ wordlist.h \ wordlist.cc -nodist_tests_testHttpParser_SOURCES = \ +nodist_tests_testHttp1Parser_SOURCES = \ $(TESTSOURCES) -tests_testHttpParser_LDADD= \ +tests_testHttp1Parser_LDADD= \ http/libsquid-http.la \ anyp/libanyp.la \ SquidConfig.o \ @@ -2557,8 +2557,8 @@ tests_testHttpParser_LDADD= \ $(SQUID_CPPUNIT_LIBS) \ $(COMPAT_LIB) \ $(XTRA_LIBS) -tests_testHttpParser_LDFLAGS = $(LIBADD_DL) -tests_testHttpParser_DEPENDENCIES = \ +tests_testHttp1Parser_LDFLAGS = $(LIBADD_DL) +tests_testHttp1Parser_DEPENDENCIES = \ $(SQUID_CPPUNIT_LA) ## Tests of the HttpRequest module. diff --git a/src/client_side.cc b/src/client_side.cc index cf8bec59fe..5f7f300f48 100644 --- a/src/client_side.cc +++ b/src/client_side.cc @@ -206,7 +206,7 @@ static IOACB httpsAccept; #endif static CTCB clientLifetimeTimeout; static ClientSocketContext *parseHttpRequestAbort(ConnStateData * conn, const char *uri); -static ClientSocketContext *parseHttpRequest(ConnStateData *, const HttpParserPointer &, HttpRequestMethod *); +static ClientSocketContext *parseHttpRequest(ConnStateData *, const Http::Http1ParserPointer &, HttpRequestMethod *); #if USE_IDENT static IDCB clientIdentDone; #endif @@ -2203,7 +2203,7 @@ prepareTransparentURL(ConnStateData * conn, ClientHttpRequest *http, char *url, * \note Sets result->flags.parsed_ok to 0 if failed to parse the request, * to 1 if the request was correctly parsed. * \param[in] csd a ConnStateData. The caller must make sure it is not null - * \param[in] hp an HttpParser + * \param[in] hp an Http::Http1Parser * \param[out] mehtod_p will be set as a side-effect of the parsing. * Pointed-to value will be set to Http::METHOD_NONE in case of * parsing failure @@ -2212,7 +2212,7 @@ prepareTransparentURL(ConnStateData * conn, ClientHttpRequest *http, char *url, * a ClientSocketContext structure on success or failure. */ static ClientSocketContext * -parseHttpRequest(ConnStateData *csd, const HttpParserPointer &hp, HttpRequestMethod * method_p) +parseHttpRequest(ConnStateData *csd, const Http::Http1ParserPointer &hp, HttpRequestMethod * method_p) { char *req_hdr = NULL; char *end; @@ -2638,7 +2638,7 @@ bool ConnStateData::serveDelayedError(ClientSocketContext *context) #endif // USE_SSL static void -clientProcessRequest(ConnStateData *conn, const HttpParserPointer &hp, ClientSocketContext *context, const HttpRequestMethod& method) +clientProcessRequest(ConnStateData *conn, const Http::Http1ParserPointer &hp, ClientSocketContext *context, const HttpRequestMethod& method) { ClientHttpRequest *http = context->http; HttpRequest::Pointer request; @@ -2992,7 +2992,7 @@ ConnStateData::clientParseRequests() // a) dont have one already // b) have completed the previous request parsing already if (!parser_ || parser_->isDone()) - parser_ = new HttpParser(in.buf, in.notYetUsed); + parser_ = new Http::Http1Parser(in.buf, in.notYetUsed); else // update the buffer space being parsed parser_->bufsiz = in.notYetUsed; diff --git a/src/client_side.h b/src/client_side.h index e024acaba0..a198a65527 100644 --- a/src/client_side.h +++ b/src/client_side.h @@ -398,9 +398,8 @@ private: Auth::UserRequest::Pointer auth_; #endif - HttpParserPointer parser_; - - // XXX: CBDATA plays with public/private and leaves the following 'private' fields all public... :( + /// the parser state for current HTTP/1.x input buffer processing + Http::Http1ParserPointer parser_; #if USE_SSL bool switchedToHttps_; diff --git a/src/http/Http1Parser.cc b/src/http/Http1Parser.cc index 1e15611d0b..f153413172 100644 --- a/src/http/Http1Parser.cc +++ b/src/http/Http1Parser.cc @@ -5,7 +5,7 @@ #include "SquidConfig.h" void -HttpParser::clear() +Http::Http1Parser::clear() { completedState_ = HTTP_PARSE_NONE; request_parse_status = Http::scNone; @@ -21,7 +21,7 @@ HttpParser::clear() } void -HttpParser::reset(const char *aBuf, int len) +Http::Http1Parser::reset(const char *aBuf, int len) { clear(); // empty the state. completedState_ = HTTP_PARSE_NEW; @@ -31,7 +31,7 @@ HttpParser::reset(const char *aBuf, int len) } int -HttpParser::parseRequestFirstLine() +Http::Http1Parser::parseRequestFirstLine() { int second_word = -1; // track the suspected URI start int first_whitespace = -1, last_whitespace = -1; // track the first and last SP byte @@ -247,7 +247,7 @@ HttpParser::parseRequestFirstLine() } bool -HttpParser::parseRequest() +Http::Http1Parser::parseRequest() { PROF_start(HttpParserParseReqLine); int retcode = parseRequestFirstLine(); diff --git a/src/http/Http1Parser.h b/src/http/Http1Parser.h index 7f32f6295a..f4bdb0087e 100644 --- a/src/http/Http1Parser.h +++ b/src/http/Http1Parser.h @@ -1,10 +1,12 @@ -#ifndef _SQUID_SRC_HTTPPARSER_H -#define _SQUID_SRC_HTTPPARSER_H +#ifndef _SQUID_SRC_Http1Parser_H +#define _SQUID_SRC_Http1Parser_H #include "base/RefCount.h" #include "http/ProtocolVersion.h" #include "http/StatusCode.h" +namespace Http { + // Parser states #define HTTP_PARSE_NONE 0 // nothing. completely unset state. #define HTTP_PARSE_NEW 1 // initialized, but nothing usefully parsed yet. @@ -19,12 +21,12 @@ * \item Request Line (method, URL, protocol, version) * \item Mime header block */ -class HttpParser : public RefCountable +class Http1Parser : public RefCountable { public: - typedef RefCount Pointer; + typedef RefCount Pointer; - HttpParser() { clear(); } + Http1Parser() { clear(); } /** Initialize a new parser. * Presenting it a buffer to work on and the current length of available @@ -32,7 +34,7 @@ public: * NOTE: This is *not* the buffer size, just the parse-able data length. * The parse routines may be called again later with more data. */ - HttpParser(const char *aBuf, int len) { reset(aBuf,len); }; + Http1Parser(const char *aBuf, int len) { reset(aBuf,len); }; /// Set this parser back to a default state. /// Will DROP any reference to a buffer (does not free). @@ -123,4 +125,6 @@ private: AnyP::ProtocolVersion msgProtocol_; }; -#endif /* _SQUID_SRC_HTTPPARSER_H */ +} // namespace Http + +#endif /* _SQUID_SRC_Http1Parser_H */ diff --git a/src/tests/testHttpParser.cc b/src/tests/testHttp1Parser.cc similarity index 99% rename from src/tests/testHttpParser.cc rename to src/tests/testHttp1Parser.cc index f019c36188..8079e21fdc 100644 --- a/src/tests/testHttpParser.cc +++ b/src/tests/testHttp1Parser.cc @@ -6,17 +6,17 @@ #define private public #define protected public -#include "testHttpParser.h" +#include "testHttp1Parser.h" #include "http/Http1Parser.h" #include "Mem.h" #include "MemBuf.h" #include "SquidConfig.h" -#include "testHttpParser.h" +#include "testHttp1Parser.h" -CPPUNIT_TEST_SUITE_REGISTRATION( testHttpParser ); +CPPUNIT_TEST_SUITE_REGISTRATION( testHttp1Parser ); void -testHttpParser::globalSetup() +testHttp1Parser::globalSetup() { static bool setup_done = false; if (setup_done) @@ -27,13 +27,13 @@ testHttpParser::globalSetup() } void -testHttpParser::testParseRequestLineProtocols() +testHttp1Parser::testParseRequestLineProtocols() { // ensure MemPools etc exist globalSetup(); MemBuf input; - HttpParser output; + Http::Http1Parser output; input.init(); // TEST: Do we comply with RFC 1945 section 5.1 ? @@ -359,13 +359,13 @@ testHttpParser::testParseRequestLineProtocols() } void -testHttpParser::testParseRequestLineStrange() +testHttp1Parser::testParseRequestLineStrange() { // ensure MemPools etc exist globalSetup(); MemBuf input; - HttpParser output; + Http::Http1Parser output; input.init(); // space padded URL @@ -442,13 +442,13 @@ testHttpParser::testParseRequestLineStrange() } void -testHttpParser::testParseRequestLineTerminators() +testHttp1Parser::testParseRequestLineTerminators() { // ensure MemPools etc exist globalSetup(); MemBuf input; - HttpParser output; + Http::Http1Parser output; input.init(); // alternative EOL sequence: NL-only @@ -645,13 +645,13 @@ testHttpParser::testParseRequestLineTerminators() } void -testHttpParser::testParseRequestLineMethods() +testHttp1Parser::testParseRequestLineMethods() { // ensure MemPools etc exist globalSetup(); MemBuf input; - HttpParser output; + Http::Http1Parser output; input.init(); // RFC 2616 : . method @@ -840,13 +840,13 @@ testHttpParser::testParseRequestLineMethods() } void -testHttpParser::testParseRequestLineInvalid() +testHttp1Parser::testParseRequestLineInvalid() { // ensure MemPools etc exist globalSetup(); MemBuf input; - HttpParser output; + Http::Http1Parser output; input.init(); // no method (but in a form which is ambiguous with HTTP/0.9 simple-request) @@ -1105,7 +1105,7 @@ testHttpParser::testParseRequestLineInvalid() } void -testHttpParser::testDripFeed() +testHttp1Parser::testDripFeed() { // Simulate a client drip-feeding Squid a few bytes at a time. // extend the size of the buffer from 0 bytes to full request length @@ -1119,7 +1119,7 @@ testHttpParser::testDripFeed() int reqLineEnd = mb.contentSize(); mb.append("\n", 1); - HttpParser hp(mb.content(), 0); + Http::Http1Parser hp(mb.content(), 0); // only relaxed parser accepts the garbage whitespace Config.onoff.relaxed_header_parser = 1; diff --git a/src/tests/testHttpParser.h b/src/tests/testHttp1Parser.h similarity index 83% rename from src/tests/testHttpParser.h rename to src/tests/testHttp1Parser.h index 065d6bcbb8..f34cf21459 100644 --- a/src/tests/testHttpParser.h +++ b/src/tests/testHttp1Parser.h @@ -1,11 +1,11 @@ -#ifndef SQUID_SRC_TESTS_TESTHTTPPARSER_H -#define SQUID_SRC_TESTS_TESTHTTPPARSER_H +#ifndef SQUID_SRC_TESTS_TESTHTTP1PARSER_H +#define SQUID_SRC_TESTS_TESTHTTP1PARSER_H #include -class testHttpParser : public CPPUNIT_NS::TestFixture +class testHttp1Parser : public CPPUNIT_NS::TestFixture { - CPPUNIT_TEST_SUITE( testHttpParser ); + CPPUNIT_TEST_SUITE( testHttp1Parser ); CPPUNIT_TEST( testParseRequestLineTerminators ); CPPUNIT_TEST( testParseRequestLineMethods ); CPPUNIT_TEST( testParseRequestLineProtocols );