Go to the documentation of this file.
43 "CRLF bytes received ahead of request-line. " <<
44 "Ignored due to relaxed_header_parser.");
47 while (!buf_.isEmpty() && (buf_[0] ==
'\n' ||
48 (buf_[0] ==
'\r' && buf_.length() > 1 && buf_[1] ==
'\n'))) {
69 static const size_t maxMethodLength = 32;
73 debugs(33,
ErrorLevel(),
"ERROR: invalid request-line: missing or malformed method");
79 if (!skipDelimiter(
tok.skipAll(DelimiterCharacters()),
"after method"))
114 #if USE_HTTP_VIOLATIONS
118 DelimiterCharacters() +
125 return RelaxedExtended;
130 DelimiterCharacters();
132 return RelaxedCompliant;
152 const size_t maxUriLength =
static_cast<size_t>((64*1024)-1);
155 if (!
tok.prefix(uriFound, RequestTargetCharacters())) {
157 debugs(33,
ErrorLevel(),
"ERROR: invalid request-line: missing or malformed URI");
161 if (uriFound.
length() > maxUriLength) {
165 "-byte URI exceeds " << maxUriLength <<
"-byte limit");
176 static const SBuf http1p0(
"HTTP/1.0");
177 static const SBuf http1p1(
"HTTP/1.1");
178 const auto savedTok =
tok;
182 if (
tok.skipSuffix(http1p1)) {
185 }
else if (
tok.skipSuffix(http1p0)) {
192 static const SBuf proto(
"HTTP/");
196 tok.skipOneTrailing(period) &&
198 tok.skipSuffix(proto)) {
199 const bool multiDigits = majorDigit.
length() > 1 || minorDigit.
length() > 1;
201 const unsigned int major = multiDigits ? 0 : (*majorDigit.
rawContent() -
'0');
202 const unsigned int minor = multiDigits ? 0 : (*minorDigit.
rawContent() -
'0');
232 debugs(33,
ErrorLevel(),
"ERROR: invalid request-line: missing delimiter " << where);
239 debugs(33,
ErrorLevel(),
"ERROR: invalid request-line: too many delimiters " << where);
255 debugs(33,
ErrorLevel(),
"ERROR: invalid request-line: missing CR before LF");
277 debugs(74, 5,
"parsing possible request: buf.length=" << buf_.length());
286 if (!lineTok.prefix(line, lineChars) || !lineTok.skip(
'\n')) {
291 if (!parseMethodField(methodTok))
300 debugs(74, 5,
"Parser needs more data");
306 if (!parseMethodField(
tok))
310 if (!skipTrailingCrs(
tok))
313 if (!parseHttpVersionField(
tok))
316 if (!http0() && !skipDelimiter(
tok.skipAllTrailing(DelimiterCharacters()),
"before protocol version"))
321 if (!parseUriField(
tok))
331 buf_ = lineTok.remaining();
338 const bool result = doParse(aBuf);
339 if (preserveParsed_) {
341 parsed_.append(aBuf.
substr(0, aBuf.
length() - remaining().length()));
367 const int retcode = parseRequestFirstLine();
374 debugs(74, 5,
"request-line: retval " << retcode <<
": line={" << aBuf.
length() <<
", data='" << aBuf <<
"'}");
375 debugs(74, 5,
"request-line: method: " << method_);
376 debugs(74, 5,
"request-line: url: " << uri_);
377 debugs(74, 5,
"request-line: proto: " << msgProtocol_);
378 debugs(74, 5,
"Parser: bytes processed=" << (aBuf.
length()-buf_.length()));
397 return !needsMoreData();
static const CharacterSet & RequestTargetCharacters()
characters which Squid will accept in the HTTP request-target (URI)
int relaxed_header_parser
bool skipDelimiter(const size_t count, const char *where)
bool parseMethodField(Tokenizer &)
@ HTTP_PARSE_MIME
HTTP/1 mime-header block.
CharacterSet complement(const char *complementLabel=nullptr) const
bool parseUriField(Tokenizer &)
struct SquidConfig::@97 onoff
int parseRequestFirstLine()
SBuf uri_
raw copy of the original client request-line URI field
const SBuf & image() const
static const CharacterSet LF
SBuf substr(size_type pos, size_type n=npos) const
Http1::Parser::size_type firstLineSize() const override
size in bytes of the first line including CRLF terminator
SBuf::size_type size_type
static const CharacterSet CR
const char * rawContent() const
HttpRequestMethod method_
what request method has been found on the first line
bool skipTrailingCrs(Tokenizer &tok)
Parse CRs at the end of request-line, just before the terminating LF.
static const CharacterSet TCHAR
static const CharacterSet HEXDIG
bool doParse(const SBuf &aBuf)
called from parse() to do the parsing
@ HTTP_PARSE_NONE
initialized, but nothing usefully parsed yet
@ scRequestHeaderFieldsTooLarge
static const CharacterSet & UriValidCharacters()
the characters which truly are valid within URI
static const CharacterSet DIGIT
size_type length() const
Returns the number of bytes stored in SBuf.
size_t maxRequestHeaderSize
@ HTTP_PARSE_FIRST
HTTP/1 message first-line.
bool parse(const SBuf &aBuf) override
@ HTTP_PARSE_DONE
parsed a message header, or reached a terminal syntax error
::Parser::Tokenizer Tokenizer
static const CharacterSet & RFC3986_UNRESERVED()
allowed URI characters that do not have a reserved purpose, RFC 3986
optimized set of C chars, with quick membership test and merge support
int ErrorLevel()
the right debugs() level for logging HTTP violation messages
bool parseHttpVersionField(Tokenizer &)
@ scHeaderTooLarge
Header too large to process.
#define debugs(SECTION, LEVEL, CONTENT)
AnyP::ProtocolVersion ProtocolVersion(unsigned int aMajor, unsigned int aMinor)
HTTP version label information.