22 static const SBuf crlf(
"\r\n");
113 mimeHeaderBlock_ =
tok.remaining();
135 const auto szLimit = mimeHeaderBlock_.length();
136 mimeHeaderBlock_.clear();
138 mimeHeaderBlock_.reserveSpace(szLimit);
142 while (!
tok.atEnd()) {
143 const SBuf all(
tok.remaining());
144 const auto blobLen =
tok.skipAll(nonCRLF);
149 mimeHeaderBlock_.append(all.
substr(0, blobLen));
150 mimeHeaderBlock_.append(
' ');
152 mimeHeaderBlock_.append(all.
substr(0, blobLen + crLen + lfLen));
160 const bool expectMime = (msgProtocol_.protocol ==
AnyP::PROTO_HTTP && msgProtocol_.major == 1) ||
169 bool containsObsFold;
173 if (firstLineSize() + mimeHeaderBytes >= limit) {
174 debugs(33, 5,
"Too large " << which);
176 buf_.consume(mimeHeaderBytes);
181 mimeHeaderBlock_ = buf_.consume(mimeHeaderBytes);
186 debugs(74, 5,
"mime header (0-" << mimeHeaderBytes <<
") {" << mimeHeaderBlock_ <<
"}");
189 if (buf_.length()+firstLineSize() >= limit) {
190 debugs(33, 5,
"Too large " << which);
194 debugs(33, 5,
"Incomplete " << which <<
", waiting for end of headers");
199 debugs(33, 3,
"Missing HTTP/1.x identifier");
208#define GET_HDR_SZ 1024
215 if (!headerBlockSize())
219 const char *name =
"Host";
220 const int namelen = strlen(name);
222 debugs(25, 5,
"looking for " << name);
237 if (p[namelen] !=
':')
243 debugs(25, 5,
"checking " << p);
252 p.
chop(0,
sizeof(header)-1);
261 debugs(25, 5,
"returning " << header);
279 const auto count =
tok.skipAll(bwsChars);
282 throw InsufficientInput();
void SBufToCstring(char *d, const SBuf &s)
optimized set of C chars, with quick membership test and merge support
CharacterSet complement(const char *complementLabel=nullptr) const
static const CharacterSet SP
CharacterSet & rename(const char *label)
change name; handy in const declarations that use operators
static const CharacterSet WSP
static const CharacterSet DIGIT
static const CharacterSet ALPHA
static const CharacterSet LF
static const CharacterSet CR
static const CharacterSet HTAB
char * getHostHeaderField()
AnyP::ProtocolVersion msgProtocol_
what protocol label has been found in the first line (if any)
static const CharacterSet & WhitespaceCharacters()
SBuf buf_
bytes remaining to be parsed
void skipLineTerminator(Tokenizer &) const
bool grabMimeBlock(const char *which, const size_t limit)
ParseState parsingStage_
what stage the parser is currently up to
static const CharacterSet & DelimiterCharacters()
SBuf mimeHeaderBlock_
buffer holding the mime headers (if any)
::Parser::Tokenizer Tokenizer
static const SBuf Http1magic
RFC 7230 section 2.6 - 7 magic octets.
int caseCmp(const SBuf &S, const size_type n) const
shorthand version for case-insensitive compare()
static const size_type npos
SBuf consume(size_type n=npos)
SBuf & chop(size_type pos, size_type n=npos)
size_type findFirstNotOf(const CharacterSet &set, size_type startPos=0) const
SBuf & trim(const SBuf &toRemove, bool atBeginning=true, bool atEnd=true)
SBuf substr(size_type pos, size_type n=npos) const
MemBlob::size_type size_type
struct SquidConfig::@90 onoff
int relaxed_header_parser
#define debugs(SECTION, LEVEL, CONTENT)
static const CharacterSet & RelaxedDelimiterCharacters()
characters HTTP permits tolerant parsers to accept as delimiters
static const CharacterSet & LineCharacters()
all characters except the LF line terminator
common part of ParseBws() and ParseStrctBws()
void ParseBws(Parser::Tokenizer &)
@ HTTP_PARSE_DONE
parsed a message header, or reached a terminal syntax error
@ HTTP_PARSE_NONE
initialized, but nothing usefully parsed yet
static void ParseBws_(Parser::Tokenizer &tok, const CharacterSet &bwsChars)
const SBuf & CrLf()
CRLF textual representation.
void ParseStrictBws(Parser::Tokenizer &)
int ErrorLevel()
the right debugs() level for logging HTTP violation messages
@ scHeaderTooLarge
Header too large to process.
#define LOCAL_ARRAY(type, name, size)