From: Amos Jeffries Date: Sat, 24 Jan 2015 12:28:38 +0000 (-0800) Subject: Shuffle skipLineTerminator() to Http1::Parser X-Git-Tag: merge-candidate-3-v1~270^2~5 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8855357057ec0e21ed5f40b25a925b83ff398ba7;p=thirdparty%2Fsquid.git Shuffle skipLineTerminator() to Http1::Parser Bring inline with location from the ResponseParser branch to reduce future merge conflicts. --- diff --git a/src/http/one/Parser.cc b/src/http/one/Parser.cc index 1bf408b023..b9bfa173a3 100644 --- a/src/http/one/Parser.cc +++ b/src/http/one/Parser.cc @@ -10,6 +10,7 @@ #include "Debug.h" #include "http/one/Parser.h" #include "parser/Tokenizer.h" +#include "SquidConfig.h" /// RFC 7230 section 2.6 - 7 magic octets const SBuf Http::One::Parser::Http1magic("HTTP/1."); @@ -23,6 +24,19 @@ Http::One::Parser::clear() mimeHeaderBlock_.clear(); } +bool +Http::One::Parser::skipLineTerminator(::Parser::Tokenizer &tok) const +{ + static const SBuf crlf("\r\n"); + if (tok.skip(crlf)) + return true; + + if (Config.onoff.relaxed_header_parser && tok.skipOne(CharacterSet::LF)) + return true; + + return false; +} + // arbitrary maximum-length for headers which can be found by Http1Parser::getHeaderField() #define GET_HDR_SZ 1024 diff --git a/src/http/one/Parser.h b/src/http/one/Parser.h index 8f0083ff8c..ff1c8d2909 100644 --- a/src/http/one/Parser.h +++ b/src/http/one/Parser.h @@ -13,6 +13,10 @@ #include "http/one/forward.h" #include "SBuf.h" +namespace Parser { +class Tokenizer; +} + namespace Http { namespace One { @@ -88,6 +92,10 @@ public: const SBuf &remaining() const {return buf_;} protected: + /// detect and skip the CRLF or (if tolerant) LF line terminator + /// consume from the tokenizer and return true only if found + bool skipLineTerminator(::Parser::Tokenizer &tok) const; + /// RFC 7230 section 2.6 - 7 magic octets static const SBuf Http1magic; diff --git a/src/http/one/RequestParser.cc b/src/http/one/RequestParser.cc index 375859ab6b..c60ef61d5e 100644 --- a/src/http/one/RequestParser.cc +++ b/src/http/one/RequestParser.cc @@ -58,21 +58,6 @@ Http::One::RequestParser::skipGarbageLines() } } -/// detect and skip the CRLF or LF line terminator -/// consume from the tokenizer and return true only if found -bool -Http::One::RequestParser::skipLineTerminator(::Parser::Tokenizer &tok) const -{ - static const SBuf crlf("\r\n"); - if (tok.skip(crlf)) - return true; - - if (Config.onoff.relaxed_header_parser && tok.skipOne(CharacterSet::LF)) - return true; - - return false; -} - /** * Attempt to parse the method field out of an HTTP message request-line. * diff --git a/src/http/one/RequestParser.h b/src/http/one/RequestParser.h index 236cd1c51c..06ec25b76c 100644 --- a/src/http/one/RequestParser.h +++ b/src/http/one/RequestParser.h @@ -57,7 +57,6 @@ private: int parseMethodField(::Parser::Tokenizer &, const CharacterSet &); int parseUriField(::Parser::Tokenizer &, const CharacterSet &); int parseHttpVersionField(::Parser::Tokenizer &); - bool skipLineTerminator(::Parser::Tokenizer &) const; /// what request method has been found on the first line HttpRequestMethod method_;