This commit is contained in:
yhirose 2024-09-07 16:07:45 -04:00
parent c673d502b9
commit 7fd346a2ca

View file

@ -4184,8 +4184,12 @@ inline bool read_content_chunked(Stream &strm, T &x,
assert(chunk_len == 0);
// Trailer
if (!line_reader.getline()) { return false; }
// NOTE: In RFC 9112, '7.1 Chunked Transfer Coding' mentiones "The chunked transfer coding is complete when a chunk with a chunk-size of zero is received, possibly followed by a trailer section, and finally terminated by an empty line". https://www.rfc-editor.org/rfc/rfc9112.html#section-7.1
//
// In '7.1.3. Decoding Chunked', however, the pseudo-code in the section does't care for the existence of the final CRLF. In other words, it seems to be ok whether the final CRLF exists or not in the chunked data. https://www.rfc-editor.org/rfc/rfc9112.html#section-7.1.3
//
// According to the reference code in RFC 9112, cpp-htpplib now allows chuncked transfer coding data without the final CRLF.
if (!line_reader.getline()) { return true; }
while (strcmp(line_reader.ptr(), "\r\n") != 0) {
if (line_reader.size() > CPPHTTPLIB_HEADER_MAX_LENGTH) { return false; }