]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Shuffle ChunkedCodingParser into Http1:: namespace
authorAmos Jeffries <squid3@treenet.co.nz>
Sun, 29 Mar 2015 04:38:29 +0000 (21:38 -0700)
committerAmos Jeffries <squid3@treenet.co.nz>
Sun, 29 Mar 2015 04:38:29 +0000 (21:38 -0700)
src/adaptation/icap/ModXact.cc
src/adaptation/icap/ModXact.h
src/client_side.cc
src/client_side.h
src/http.cc
src/http.h
src/http/one/ChunkedCodingParser.cc
src/http/one/ChunkedCodingParser.h
src/http/one/forward.h

index c4af75942e02487cf570893e60bd5927273539e4..638bb7f98538c41050001cf1afe31731d376ba8e 100644 (file)
@@ -1104,7 +1104,7 @@ void Adaptation::Icap::ModXact::decideOnParsingBody()
         debugs(93, 5, HERE << "expecting a body");
         state.parsing = State::psBody;
         replyHttpBodySize = 0;
-        bodyParser = new ChunkedCodingParser;
+        bodyParser = new Http1::ChunkedCodingParser;
         makeAdaptedBodyPipe("adapted response from the ICAP server");
         Must(state.sending == State::sendingAdapted);
     } else {
index a186e0a0f5a326f1d5d669d112770de50714c686..56e4bc9d1a21b600ec878e9f2259a9891374f7a9 100644 (file)
@@ -14,6 +14,7 @@
 #include "adaptation/icap/Launcher.h"
 #include "adaptation/icap/Xaction.h"
 #include "BodyPipe.h"
+#include "http/one/forward.h"
 
 /*
  * ICAPModXact implements ICAP REQMOD and RESPMOD transaction using
@@ -25,8 +26,6 @@
  * receive the HTTP body.
  */
 
-class ChunkedCodingParser;
-
 namespace Adaptation
 {
 namespace Icap
@@ -250,7 +249,7 @@ private:
     uint64_t virginConsumed;        // virgin data consumed so far
     Preview preview; // use for creating (writing) the preview
 
-    ChunkedCodingParser *bodyParser; // ICAP response body parser
+    Http1::ChunkedCodingParser *bodyParser; // ICAP response body parser
 
     bool canStartBypass; // enables bypass of transaction failures
     bool protectGroupBypass; // protects ServiceGroup-wide bypass of failures
index 9c4b0d119b32f8ab55ffcb314b8984e1c4ad33ed..6493a76bbe7d031a40080ce6b0040563f9288ff3 100644 (file)
@@ -3275,7 +3275,7 @@ ConnStateData::handleChunkedRequestBody(size_t &putSize)
         if (in.buf.isEmpty()) // nothing to do
             return ERR_NONE;
 
-        MemBuf raw; // ChunkedCodingParser only works with MemBufs
+        MemBuf raw; // Http1::ChunkedCodingParser only works with MemBufs
         // add one because MemBuf will assert if it cannot 0-terminate
         raw.init(in.buf.length(), in.buf.length()+1);
         raw.append(in.buf.c_str(), in.buf.length());
@@ -4773,7 +4773,7 @@ ConnStateData::startDechunkingRequest()
     Must(bodyPipe != NULL);
     debugs(33, 5, HERE << "start dechunking" << bodyPipe->status());
     assert(!in.bodyParser);
-    in.bodyParser = new ChunkedCodingParser;
+    in.bodyParser = new Http1::ChunkedCodingParser;
 }
 
 /// put parsed content into input buffer and clean up
index 1e93498778da6e5121466f5a26d6c3dc375b1a4e..9c17e95142af896ef6c657a1577eff28a018164b 100644 (file)
@@ -28,7 +28,6 @@
 class ConnStateData;
 class ClientHttpRequest;
 class clientStreamNode;
-class ChunkedCodingParser;
 namespace AnyP
 {
 class PortCfg;
@@ -208,7 +207,7 @@ public:
         ~In();
         bool maybeMakeSpaceAvailable();
 
-        ChunkedCodingParser *bodyParser; ///< parses chunked request body
+        Http1::ChunkedCodingParser *bodyParser; ///< parses chunked request body
         SBuf buf;
     } in;
 
index 7f7cde90b0d3d0b02e501f58f210bc38980e53fa..c6d4a7b2f9b4a8f39d1b6a3936770530ca7cae2e 100644 (file)
@@ -788,7 +788,7 @@ HttpStateData::processReplyHeader()
     flags.chunked = false;
     if (newrep->sline.protocol == AnyP::PROTO_HTTP && newrep->header.chunked()) {
         flags.chunked = true;
-        httpChunkDecoder = new ChunkedCodingParser;
+        httpChunkDecoder = new Http1::ChunkedCodingParser;
     }
 
     if (!peerSupportsConnectionPinning())
index 53f5f60d50304f30931fa158a9a3bd9930432953..6b812838a9f580f18d363794a56b5ca6237728fd 100644 (file)
@@ -11,9 +11,9 @@
 
 #include "clients/Client.h"
 #include "comm.h"
+#include "http/forward.h"
 #include "HttpStateFlags.h"
 
-class ChunkedCodingParser;
 class FwdState;
 class HttpHeader;
 
@@ -120,7 +120,7 @@ private:
 
     /// Parser being used at present to parse the HTTP/ICY server response.
     Http1::ResponseParserPointer hp;
-    ChunkedCodingParser *httpChunkDecoder;
+    Http1::ChunkedCodingParser *httpChunkDecoder;
 
     /// amount of message payload/body received so far.
     int64_t payloadSeen;
index c74ddae0894674f2f6613da45e98edfbf48e5ded..aabbf281343c371157989e2afcf8a62263261d37 100644 (file)
 #include "MemBuf.h"
 #include "Parsing.h"
 
-ChunkedCodingParser::Step ChunkedCodingParser::psChunkSize = &ChunkedCodingParser::parseChunkSize;
-ChunkedCodingParser::Step ChunkedCodingParser::psUnusedChunkExtension = &ChunkedCodingParser::parseUnusedChunkExtension;
-ChunkedCodingParser::Step ChunkedCodingParser::psLastChunkExtension = &ChunkedCodingParser::parseLastChunkExtension;
-ChunkedCodingParser::Step ChunkedCodingParser::psChunkBody = &ChunkedCodingParser::parseChunkBody;
-ChunkedCodingParser::Step ChunkedCodingParser::psChunkEnd = &ChunkedCodingParser::parseChunkEnd;
-ChunkedCodingParser::Step ChunkedCodingParser::psTrailer = &ChunkedCodingParser::parseTrailer;
-ChunkedCodingParser::Step ChunkedCodingParser::psMessageEnd = &ChunkedCodingParser::parseMessageEnd;
-
-ChunkedCodingParser::ChunkedCodingParser()
+Http::One::ChunkedCodingParser::Step Http::One::ChunkedCodingParser::psChunkSize = &Http::One::ChunkedCodingParser::parseChunkSize;
+Http::One::ChunkedCodingParser::Step Http::One::ChunkedCodingParser::psUnusedChunkExtension = &Http::One::ChunkedCodingParser::parseUnusedChunkExtension;
+Http::One::ChunkedCodingParser::Step Http::One::ChunkedCodingParser::psLastChunkExtension = &Http::One::ChunkedCodingParser::parseLastChunkExtension;
+Http::One::ChunkedCodingParser::Step Http::One::ChunkedCodingParser::psChunkBody = &Http::One::ChunkedCodingParser::parseChunkBody;
+Http::One::ChunkedCodingParser::Step Http::One::ChunkedCodingParser::psChunkEnd = &Http::One::ChunkedCodingParser::parseChunkEnd;
+Http::One::ChunkedCodingParser::Step Http::One::ChunkedCodingParser::psTrailer = &Http::One::ChunkedCodingParser::parseTrailer;
+Http::One::ChunkedCodingParser::Step Http::One::ChunkedCodingParser::psMessageEnd = &Http::One::ChunkedCodingParser::parseMessageEnd;
+
+Http::One::ChunkedCodingParser::ChunkedCodingParser()
 {
     reset();
 }
 
-void ChunkedCodingParser::reset()
+void
+Http::One::ChunkedCodingParser::reset()
 {
     theStep = psChunkSize;
     theChunkSize = theLeftBodySize = 0;
@@ -36,7 +37,8 @@ void ChunkedCodingParser::reset()
     inQuoted = inSlashed = false;
 }
 
-bool ChunkedCodingParser::parse(MemBuf *rawData, MemBuf *parsedContent)
+bool
+Http::One::ChunkedCodingParser::parse(MemBuf *rawData, MemBuf *parsedContent)
 {
     Must(rawData && parsedContent);
     theIn = rawData;
@@ -53,23 +55,27 @@ bool ChunkedCodingParser::parse(MemBuf *rawData, MemBuf *parsedContent)
     return theStep == psMessageEnd;
 }
 
-bool ChunkedCodingParser::needsMoreData() const
+bool
+Http::One::ChunkedCodingParser::needsMoreData() const
 {
     return doNeedMoreData;
 }
 
-bool ChunkedCodingParser::needsMoreSpace() const
+bool
+Http::One::ChunkedCodingParser::needsMoreSpace() const
 {
     assert(theOut);
     return theStep == psChunkBody && !theOut->hasPotentialSpace();
 }
 
-bool ChunkedCodingParser::mayContinue() const
+bool
+Http::One::ChunkedCodingParser::mayContinue() const
 {
     return !needsMoreData() && !needsMoreSpace() && theStep != psMessageEnd;
 }
 
-void ChunkedCodingParser::parseChunkSize()
+void
+Http::One::ChunkedCodingParser::parseChunkSize()
 {
     Must(theChunkSize <= 0); // Should(), really
 
@@ -98,7 +104,8 @@ void ChunkedCodingParser::parseChunkSize()
         throw TexcHere("corrupted chunk size");
 }
 
-void ChunkedCodingParser::parseUnusedChunkExtension()
+void
+Http::One::ChunkedCodingParser::parseUnusedChunkExtension()
 {
     size_t crlfBeg = 0;
     size_t crlfEnd = 0;
@@ -112,7 +119,8 @@ void ChunkedCodingParser::parseUnusedChunkExtension()
     }
 }
 
-void ChunkedCodingParser::parseChunkBody()
+void
+Http::One::ChunkedCodingParser::parseChunkBody()
 {
     Must(theLeftBodySize > 0); // Should, really
 
@@ -132,7 +140,8 @@ void ChunkedCodingParser::parseChunkBody()
         Must(needsMoreData() || needsMoreSpace());
 }
 
-void ChunkedCodingParser::parseChunkEnd()
+void
+Http::One::ChunkedCodingParser::parseChunkEnd()
 {
     Must(theLeftBodySize == 0); // Should(), really
 
@@ -154,7 +163,8 @@ void ChunkedCodingParser::parseChunkEnd()
     doNeedMoreData = true;
 }
 
-void ChunkedCodingParser::parseTrailer()
+void
+Http::One::ChunkedCodingParser::parseTrailer()
 {
     Must(theChunkSize == 0); // Should(), really
 
@@ -162,7 +172,8 @@ void ChunkedCodingParser::parseTrailer()
         parseTrailerHeader();
 }
 
-void ChunkedCodingParser::parseTrailerHeader()
+void
+Http::One::ChunkedCodingParser::parseTrailerHeader()
 {
     size_t crlfBeg = 0;
     size_t crlfEnd = 0;
@@ -185,14 +196,16 @@ void ChunkedCodingParser::parseTrailerHeader()
     doNeedMoreData = true;
 }
 
-void ChunkedCodingParser::parseMessageEnd()
+void
+Http::One::ChunkedCodingParser::parseMessageEnd()
 {
     // termination step, should not be called
     Must(false); // Should(), really
 }
 
 /// Finds next CRLF. Does not store parsing state.
-bool ChunkedCodingParser::findCrlf(size_t &crlfBeg, size_t &crlfEnd)
+bool
+Http::One::ChunkedCodingParser::findCrlf(size_t &crlfBeg, size_t &crlfEnd)
 {
     bool quoted = false;
     bool slashed = false;
@@ -201,7 +214,8 @@ bool ChunkedCodingParser::findCrlf(size_t &crlfBeg, size_t &crlfEnd)
 
 /// Finds next CRLF. Parsing state stored in quoted and slashed
 /// parameters. Incremental: can resume when more data is available.
-bool ChunkedCodingParser::findCrlf(size_t &crlfBeg, size_t &crlfEnd, bool &quoted, bool &slashed)
+bool
+Http::One::ChunkedCodingParser::findCrlf(size_t &crlfBeg, size_t &crlfEnd, bool &quoted, bool &slashed)
 {
     // XXX: This code was copied, with permission, from another software.
     // There is a similar and probably better code inside httpHeaderParse
@@ -263,7 +277,8 @@ bool ChunkedCodingParser::findCrlf(size_t &crlfBeg, size_t &crlfEnd, bool &quote
 }
 
 // chunk-extension= *( ";" chunk-ext-name [ "=" chunk-ext-val ] )
-void ChunkedCodingParser::parseLastChunkExtension()
+void
+Http::One::ChunkedCodingParser::parseLastChunkExtension()
 {
     size_t crlfBeg = 0;
     size_t crlfEnd = 0;
index 733dc056397e4328daaf9a41eb43b2bf968608ca..f7e9753eedcfbac371a070d0fb5c7506a0f42412 100644 (file)
@@ -6,16 +6,24 @@
  * Please see the COPYING and CONTRIBUTORS files for details.
  */
 
-#ifndef SQUID_CHUNKEDCODINGPARSER_H
-#define SQUID_CHUNKEDCODINGPARSER_H
+#ifndef SQUID_SRC_HTTP_ONE_CHUNKEDCODINGPARSER_H
+#define SQUID_SRC_HTTP_ONE_CHUNKEDCODINGPARSER_H
+
+#include "http/one/forward.h"
 
 class MemBuf;
 
+namespace Http
+{
+namespace One
+{
+
 /**
- \ingroup ChunkEncodingAPI Chunked Encoding API
- \par
  * ChunkedCodingParser is an incremental parser for chunked transfer coding
- * used by HTTP and ICAP. The parser shovels content bytes from the raw
+ * defined in RFC 7230 section 4.1.
+ * http://tools.ietf.org/html/rfc7230#section-4.1
+ *
+ * The parser shovels content bytes from the raw
  * input buffer into the content output buffer, both caller-supplied.
  * Ignores chunk extensions except for ICAP's ieof.
  * Has a trailer-handling placeholder.
@@ -39,7 +47,7 @@ public:
     bool needsMoreSpace() const;
 
 private:
-    typedef void (ChunkedCodingParser::*Step)();
+    typedef void (Http1::ChunkedCodingParser::*Step)();
 
 private:
     bool mayContinue() const;
@@ -80,5 +88,8 @@ public:
     int64_t useOriginBody;
 };
 
-#endif /* SQUID_CHUNKEDCODINGPARSER_H */
+} // namespace One
+} // namespace Http
+
+#endif /* SQUID_SRC_HTTP_ONE_CHUNKEDCODINGPARSER_H */
 
index d7bf5ced118c8513bec64846cec58058fa512c35..afb4b5b88f9841c9a10ad93b4fe9bb782422236b 100644 (file)
@@ -17,6 +17,8 @@ namespace One {
 class Parser;
 typedef RefCount<Http::One::Parser> ParserPointer;
 
+class ChunkedCodingParser;
+
 class RequestParser;
 typedef RefCount<Http::One::RequestParser> RequestParserPointer;