22 customExtensionValueParser(nullptr)
35 theChunkSize = theLeftBodySize = 0;
54 Must(!buf_.isEmpty() && theOut);
78 return !needsMoreData() && !needsMoreSpace();
92 Must(theChunkSize <= 0);
94 static const SBuf bannedHexPrefixLower(
"0x");
95 static const SBuf bannedHexPrefixUpper(
"0X");
96 if (
tok.skip(bannedHexPrefixLower) ||
tok.skip(bannedHexPrefixUpper))
100 if (
tok.int64(
size, 16,
false) && !
tok.atEnd()) {
102 throw TexcHere(
"negative chunk size");
104 theChunkSize = theLeftBodySize =
size;
105 debugs(94,7,
"found chunk: " << theChunkSize);
106 buf_ =
tok.remaining();
110 }
else if (
tok.atEnd()) {
115 throw TexcHere(
"corrupted chunk size");
132 parseChunkExtensions(
tok);
134 buf_ =
tok.remaining();
137 }
catch (
const InsufficientInput &) {
150 auto tok = callerTok;
157 parseOneChunkExtension(
tok);
158 buf_ =
tok.remaining();
167 debugs(94, 5, extName <<
" with value " << ignoredValue);
175 auto tok = callerTok;
190 if (!theChunkSize && customExtensionValueParser)
191 customExtensionValueParser->parse(
tok, extName);
201 if (theLeftBodySize > 0) {
202 buf_ =
tok.remaining();
205 const size_t availSize =
min(theLeftBodySize, (uint64_t)buf_.length());
206 const size_t safeSize =
min(availSize, (
size_t)theOut->potentialSpaceSize());
208 theOut->append(buf_.rawContent(), safeSize);
209 buf_.consume(safeSize);
210 theLeftBodySize -= safeSize;
215 if (theLeftBodySize == 0)
216 return parseChunkEnd(
tok);
218 Must(needsMoreData() || needsMoreSpace());
226 Must(theLeftBodySize == 0);
230 buf_ =
tok.remaining();
235 catch (
const InsufficientInput &) {
#define Here()
source code location of the caller
#define TexcHere(msg)
legacy convenience macro; it is not difficult to type Here() now
static const CharacterSet TCHAR
::Parser::Tokenizer Tokenizer
static void Ignore(Tokenizer &tok, const SBuf &extName)
extracts and ignores the value of a named extension
::Parser::Tokenizer Tokenizer
bool parseChunkBody(Tokenizer &tok)
bool parse(const SBuf &) override
void parseChunkExtensions(Tokenizer &)
bool parseChunkSize(Tokenizer &tok)
RFC 7230 section 4.1 chunk-size.
void parseOneChunkExtension(Tokenizer &)
bool parseChunkEnd(Tokenizer &tok)
bool parseChunkMetadataSuffix(Tokenizer &)
bool needsMoreSpace() const
size_type length() const
Returns the number of bytes stored in SBuf.
an std::runtime_error with thrower location info
A const & min(A const &lhs, A const &rhs)
#define debugs(SECTION, LEVEL, CONTENT)
void ParseBws(Parser::Tokenizer &)
@ HTTP_PARSE_CHUNK_EXT
HTTP/1.1 chunked encoding chunk-ext.
@ HTTP_PARSE_CHUNK_SZ
HTTP/1.1 chunked encoding chunk-size.
@ HTTP_PARSE_MIME
HTTP/1 mime-header block.
@ HTTP_PARSE_NONE
initialized, but nothing usefully parsed yet
@ HTTP_PARSE_CHUNK
HTTP/1.1 chunked encoding chunk-data.
const SBuf & CrLf()
CRLF textual representation.
void ParseStrictBws(Parser::Tokenizer &)
SBuf tokenOrQuotedString(Parser::Tokenizer &tok, const bool http1p0=false)
AnyP::ProtocolVersion ProtocolVersion()