]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Audit followup: rename Http1Parser Http1::RequestParser
authorAmos Jeffries <squid3@treenet.co.nz>
Sat, 4 Jan 2014 13:05:51 +0000 (05:05 -0800)
committerAmos Jeffries <squid3@treenet.co.nz>
Sat, 4 Jan 2014 13:05:51 +0000 (05:05 -0800)
Create Http::One:: / Http1:: namespace accordingly.

TODO: rename files once APi shuffling has been completed.

src/client_side.cc
src/client_side.h
src/http/Http1Parser.cc
src/http/Http1Parser.h
src/http/forward.h
src/tests/testHttp1Parser.cc

index 9a6d8c0f3c4844bc04a74f0c18d6189452ea56f2..cff753a68c4dd48e7ee8aa8755547c2d6a89a777 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 *, Http::Http1Parser &);
+static ClientSocketContext *parseHttpRequest(ConnStateData *, Http1::RequestParser &);
 #if USE_IDENT
 static IDCB clientIdentDone;
 #endif
@@ -2080,7 +2080,7 @@ setLogUri(ClientHttpRequest * http, char const *uri, bool cleanUrl)
 }
 
 static void
-prepareAcceleratedURL(ConnStateData * conn, ClientHttpRequest *http, Http::Http1Parser &hp)
+prepareAcceleratedURL(ConnStateData * conn, ClientHttpRequest *http, Http1::RequestParser &hp)
 {
     int vhost = conn->port->vhost;
     int vport = conn->port->vport;
@@ -2172,7 +2172,7 @@ prepareAcceleratedURL(ConnStateData * conn, ClientHttpRequest *http, Http::Http1
 }
 
 static void
-prepareTransparentURL(ConnStateData * conn, ClientHttpRequest *http, Http::Http1Parser &hp)
+prepareTransparentURL(ConnStateData * conn, ClientHttpRequest *http, Http1::RequestParser &hp)
 {
     static char ipbuf[MAX_IPSTRLEN];
 
@@ -2205,7 +2205,7 @@ prepareTransparentURL(ConnStateData * conn, ClientHttpRequest *http, Http::Http1
  *  \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 Http::Http1Parser
+ *  \param[in] hp an Http1::RequestParser
  *  \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
@@ -2214,7 +2214,7 @@ prepareTransparentURL(ConnStateData * conn, ClientHttpRequest *http, Http::Http1
  *          a ClientSocketContext structure on success or failure.
  */
 static ClientSocketContext *
-parseHttpRequest(ConnStateData *csd, Http::Http1Parser &hp)
+parseHttpRequest(ConnStateData *csd, Http1::RequestParser &hp)
 {
     /* NP: don't be tempted to move this down or remove again.
      * It's the only DDoS protection old-String has against long URL */
@@ -2591,7 +2591,7 @@ bool ConnStateData::serveDelayedError(ClientSocketContext *context)
 #endif // USE_SSL
 
 static void
-clientProcessRequest(ConnStateData *conn, Http::Http1Parser &hp, ClientSocketContext *context)
+clientProcessRequest(ConnStateData *conn, Http1::RequestParser &hp, ClientSocketContext *context)
 {
     ClientHttpRequest *http = context->http;
     HttpRequest::Pointer request;
@@ -2943,7 +2943,7 @@ ConnStateData::clientParseRequests()
         // a) dont have one already
         // b) have completed the previous request parsing already
         if (!parser_ || parser_->isDone())
-            parser_ = new Http::Http1Parser(in.buf, in.notYetUsed);
+            parser_ = new Http1::RequestParser(in.buf, in.notYetUsed);
         else // update the buffer space being parsed
             parser_->bufsiz = in.notYetUsed;
 
index a198a655270e8f71d911d1013fff35483da9f64a..a5f5cbe01212ce7368a63191ca371318248b97e0 100644 (file)
@@ -399,7 +399,7 @@ private:
 #endif
 
     /// the parser state for current HTTP/1.x input buffer processing
-    Http::Http1ParserPointer parser_;
+    Http1::RequestParserPointer parser_;
 
 #if USE_SSL
     bool switchedToHttps_;
index 0b16f7f526d869112e3de8eabba50f3f07db4739..90b7ec2247b71e0cbcb8cbe09148713e398c6979 100644 (file)
@@ -7,7 +7,7 @@
 #include "SquidConfig.h"
 
 void
-Http::Http1Parser::clear()
+Http1::RequestParser::clear()
 {
     completedState_ = HTTP_PARSE_NONE;
     request_parse_status = Http::scNone;
@@ -24,7 +24,7 @@ Http::Http1Parser::clear()
 }
 
 void
-Http::Http1Parser::reset(const char *aBuf, int len)
+Http1::RequestParser::reset(const char *aBuf, int len)
 {
     clear(); // empty the state.
     completedState_ = HTTP_PARSE_NEW;
@@ -52,7 +52,7 @@ Http::Http1Parser::reset(const char *aBuf, int len)
  * \return true if garbage whitespace was found
  */
 bool
-Http::Http1Parser::skipGarbageLines()
+Http1::RequestParser::skipGarbageLines()
 {
     req.start = parseOffset_; // avoid re-parsing any portion we managed to complete
 
@@ -105,7 +105,7 @@ Http::Http1Parser::skipGarbageLines()
  * \retval  0  more data is needed to complete the parse
  */
 int
-Http::Http1Parser::parseRequestFirstLine()
+Http1::RequestParser::parseRequestFirstLine()
 {
     int second_word = -1; // track the suspected URI start
     int first_whitespace = -1, last_whitespace = -1; // track the first and last SP byte
@@ -315,7 +315,7 @@ Http::Http1Parser::parseRequestFirstLine()
 }
 
 bool
-Http::Http1Parser::parseRequest()
+Http1::RequestParser::parseRequest()
 {
     // stage 1: locate the request-line
     if (completedState_ == HTTP_PARSE_NEW) {
@@ -369,7 +369,7 @@ Http::Http1Parser::parseRequest()
 #define GET_HDR_SZ     1024
 
 char *
-Http::Http1Parser::getHeaderField(const char *name)
+Http1::RequestParser::getHeaderField(const char *name)
 {
     LOCAL_ARRAY(char, header, GET_HDR_SZ);
     const char *p = NULL;
index bb6a6855f5614e7f63f7b621a46c4daf0bf0f900..055afa9eff0aca8b9dc050986b1ca9e30cc81b02 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef _SQUID_SRC_HTTP_HTTP1PARSER_H
-#define _SQUID_SRC_HTTP_HTTP1PARSER_H
+#ifndef _SQUID_SRC_HTTP_ONEREQUESTPARSER_H
+#define _SQUID_SRC_HTTP_ONEREQUESTPARSER_H
 
 #include "base/RefCount.h"
 #include "http/forward.h"
@@ -9,6 +9,7 @@
 #include "SBuf.h"
 
 namespace Http {
+namespace One {
 
 // Parser states
 #define HTTP_PARSE_NONE   0 // nothing. completely unset state.
@@ -25,12 +26,10 @@ namespace Http {
  * \item Request Line (method, URL, protocol, version)
  * \item Mime header block
  */
-class Http1Parser : public RefCountable
+class RequestParser : public RefCountable
 {
 public:
-    typedef RefCount<Http1Parser> Pointer;
-
-    Http1Parser() { clear(); }
+    RequestParser() { clear(); }
 
     /** Initialize a new parser.
      * Presenting it a buffer to work on and the current length of available
@@ -38,7 +37,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.
      */
-    Http1Parser(const char *aBuf, int len) { reset(aBuf,len); };
+    RequestParser(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).
@@ -131,6 +130,7 @@ private:
     SBuf mimeHeaderBlock_;
 };
 
+} // namespace One
 } // namespace Http
 
 #endif /*  _SQUID_SRC_HTTP_HTTP1PARSER_H */
index 80258dc7ed03c268afdb100f09ad82fbe86c9b05..adee4c3e85823c6a9eb4d9ba7f3b12fb61443a6b 100644 (file)
@@ -15,12 +15,13 @@ typedef RefCount<HttpReply> HttpReplyPointer;
 
 namespace Http {
 
-class Http1Parser;
-typedef RefCount<Http1Parser> Http1ParserPointer;
-
-//class ParserBase;
-//typedef RefCount<Http::ParserBase> HttpParserPointer;
+namespace One {
+class RequestParser;
+typedef RefCount<Http::One::RequestParser> RequestParserPointer;
+} // namespace One
 
 } // namespace Http
 
+namespace Http1 = Http::One;
+
 #endif /* SQUID_SRC_HTTP_FORWARD_H */
index 86acac2d92a0125acc2585e80eddc79461daabe7..8e38503f77893fc628368d21477c19a51523d332 100644 (file)
@@ -34,7 +34,7 @@ testHttp1Parser::testParseRequestLineProtocols()
     globalSetup();
 
     MemBuf input;
-    Http::Http1Parser output;
+    Http1::RequestParser output;
     input.init();
 
     // TEST: Do we comply with RFC 1945 section 5.1 ?
@@ -384,7 +384,7 @@ testHttp1Parser::testParseRequestLineStrange()
     globalSetup();
 
     MemBuf input;
-    Http::Http1Parser output;
+    Http1::RequestParser output;
     input.init();
 
     // space padded URL
@@ -473,7 +473,7 @@ testHttp1Parser::testParseRequestLineTerminators()
     globalSetup();
 
     MemBuf input;
-    Http::Http1Parser output;
+    Http1::RequestParser output;
     input.init();
 
     // alternative EOL sequence: NL-only
@@ -687,7 +687,7 @@ testHttp1Parser::testParseRequestLineMethods()
     globalSetup();
 
     MemBuf input;
-    Http::Http1Parser output;
+    Http1::RequestParser output;
     input.init();
 
     // RFC 2616 : . method
@@ -896,7 +896,7 @@ testHttp1Parser::testParseRequestLineInvalid()
     globalSetup();
 
     MemBuf input;
-    Http::Http1Parser output;
+    Http1::RequestParser output;
     input.init();
 
     // no method (but in a form which is ambiguous with HTTP/0.9 simple-request)
@@ -1184,7 +1184,7 @@ testHttp1Parser::testDripFeed()
     int reqLineEnd = mb.contentSize();
     mb.append("Host: example.com\r\n\r\n.", 22);
 
-    Http::Http1Parser hp(mb.content(), 0);
+    Http1::RequestParser hp(mb.content(), 0);
 
     // only relaxed parser accepts the garbage whitespace
     Config.onoff.relaxed_header_parser = 1;