]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Rename HttpParser as Http::Http1Parser
authorAmos Jeffries <squid3@treenet.co.nz>
Mon, 23 Dec 2013 12:16:33 +0000 (04:16 -0800)
committerAmos Jeffries <squid3@treenet.co.nz>
Mon, 23 Dec 2013 12:16:33 +0000 (04:16 -0800)
src/Makefile.am
src/client_side.cc
src/client_side.h
src/http/Http1Parser.cc
src/http/Http1Parser.h
src/tests/testHttp1Parser.cc [moved from src/tests/testHttpParser.cc with 99% similarity]
src/tests/testHttp1Parser.h [moved from src/tests/testHttpParser.h with 83% similarity]

index 87f1fcc4145c5b21e31ec1bd6e3ace3a521a5d68..5c7f248efff0397dec1dd82071ffb502626251e4 100644 (file)
@@ -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.
index cf8bec59fef548fedf163ff42c2506b2febd0f4e..5f7f300f482a92b315b4328dcb8b81cf5bc61844 100644 (file)
@@ -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;
 
index e024acaba0bbf9cdbad8d158280a98ea26f2363d..a198a655270e8f71d911d1013fff35483da9f64a 100644 (file)
@@ -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_;
index 1e15611d0bed6c09e580ce6e9ab3478d6f2eda23..f153413172a1a0cd5a5839a187eab2c72757dbdf 100644 (file)
@@ -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();
index 7f32f6295a695e2abef350402aef1dfae4ac3d9c..f4bdb0087e73388143e7500a9bbd81dea1d876ea 100644 (file)
@@ -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.
  * \item Request Line (method, URL, protocol, version)
  * \item Mime header block
  */
-class HttpParser : public RefCountable
+class Http1Parser : public RefCountable
 {
 public:
-    typedef RefCount<HttpParser> Pointer;
+    typedef RefCount<Http1Parser> 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 */
similarity index 99%
rename from src/tests/testHttpParser.cc
rename to src/tests/testHttp1Parser.cc
index f019c36188e8601e2aec9a84afcdf3f341764cba..8079e21fdcc51e1aef63c17ae1cfbb8ef2df31e5 100644 (file)
@@ -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;
similarity index 83%
rename from src/tests/testHttpParser.h
rename to src/tests/testHttp1Parser.h
index 065d6bcbb8e25bcc5c57d9cb8862611c588c4e99..f34cf214591080cb8945b63ebe75d1413d6e0d6b 100644 (file)
@@ -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 <cppunit/extensions/HelperMacros.h>
 
-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 );