]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Cleanup: drop parsedCount_ tracking
authorAmos Jeffries <squid3@treenet.co.nz>
Tue, 20 May 2014 11:00:04 +0000 (04:00 -0700)
committerAmos Jeffries <squid3@treenet.co.nz>
Tue, 20 May 2014 11:00:04 +0000 (04:00 -0700)
Now that parse() is receiving a buffer directly we no longer have to
track how many bytes have been consumed by the parse. It can be
calculated by comparing the current and original SBuf.

src/http/one/Parser.cc
src/http/one/Parser.h
src/http/one/RequestParser.cc

index 3b2fd19874273d27e89a8c392c35c21dd3b09cb2..c6b406a5b96ca1d421a365ea0c5632cb95d3853d 100644 (file)
@@ -7,7 +7,6 @@ Http::One::Parser::clear()
 {
     parsingStage_ = HTTP_PARSE_NONE;
     buf = NULL;
-    parsedCount_ = 0;
     msgProtocol_ = AnyP::ProtocolVersion();
     mimeHeaderBlock_.clear();
 }
index e65a51e3f087c4022b5c93bc100159900540c96c..aacb0def387f13f01aaae65cd660bb9bea2410ab 100644 (file)
@@ -78,9 +78,6 @@ protected:
     /// what stage the parser is currently up to
     ParseState parsingStage_;
 
-    /// total count of bytes parsed and consumed by the parser so far
-    size_t parsedCount_;
-
     /// what protocol label has been found in the first line (if any)
     AnyP::ProtocolVersion msgProtocol_;
 
index e5ecd1665daaaad3ab0c59fc77fe4ef7bd063b26..8147a60abf4b50006ed2cea54cdbe37cb49913f0 100644 (file)
@@ -50,7 +50,6 @@ Http::One::RequestParser::skipGarbageLines()
         // ie any series of either \n or \r\n with no other characters and no repeated \r
         while (!buf.isEmpty() && (buf[0] == '\n' || (buf[0] == '\r' && buf[1] == '\n'))) {
             buf.consume(1);
-            ++parsedCount_;
         }
     }
 #endif
@@ -70,7 +69,6 @@ Http::One::RequestParser::skipGarbageLines()
         // Be tolerant of prefix spaces (other bytes are valid method values)
         while (!buf.isEmpty() && buf[0] == ' ') {
             buf.consume(1);
-            ++parsedCount_;
         }
     }
 #endif
@@ -98,7 +96,7 @@ Http::One::RequestParser::parseRequestFirstLine()
     int first_whitespace = -1, last_whitespace = -1; // track the first and last SP byte
     int line_end = -1; // tracks the last byte BEFORE terminal \r\n or \n sequence
 
-    debugs(74, 5, "parsing possible request: buf.length=" << buf.length() << ", offset=" << parsedCount_);
+    debugs(74, 5, "parsing possible request: buf.length=" << buf.length());
     debugs(74, DBG_DATA, buf);
 
     // Single-pass parse: (provided we have the whole line anyways)
@@ -323,7 +321,6 @@ Http::One::RequestParser::parseRequestFirstLine()
 bool
 Http::One::RequestParser::parse(const SBuf &aBuf)
 {
-    parsedCount_ = 0;
     buf = aBuf;
     debugs(74, DBG_DATA, "Parse buf={length=" << aBuf.length() << ", data='" << aBuf << "'}");
 
@@ -347,7 +344,7 @@ Http::One::RequestParser::parse(const SBuf &aBuf)
         debugs(74, 5, "request-line: method " << req.m_start << "->" << req.m_end << " (" << method_ << ")");
         debugs(74, 5, "request-line: url " << req.u_start << "->" << req.u_end << " (" << uri_ << ")");
         debugs(74, 5, "request-line: proto " << req.v_start << "->" << req.v_end << " (" << msgProtocol_ << ")");
-        debugs(74, 5, "Parser: bytes processed=" << parsedCount_);
+        debugs(74, 5, "Parser: bytes processed=" << (aBuf.length()-buf.length()));
         PROF_stop(HttpParserParseReqLine);
 
         // syntax errors already
@@ -358,8 +355,7 @@ Http::One::RequestParser::parse(const SBuf &aBuf)
 
         // first-line (or a look-alike) found successfully.
         if (retcode > 0) {
-            buf.consume(firstLineSize());// first line bytes including CRLF terminator are now done.
-            parsedCount_ += firstLineSize();
+            buf.consume(firstLineSize()); // first line bytes including CRLF terminator are now done.
             parsingStage_ = HTTP_PARSE_MIME;
         }
     }
@@ -384,7 +380,6 @@ Http::One::RequestParser::parse(const SBuf &aBuf)
             }
             mimeHeaderBlock_ = buf.substr(req.end+1, mimeHeaderBytes);
             buf.consume(mimeHeaderBytes); // done with these bytes now.
-            parsedCount_ += mimeHeaderBytes;
 
         } else
             debugs(33, 3, "Missing HTTP/1.x identifier");