Software /
code /
prosody
Diff
net/http/parser.lua @ 12890:05b3b3dc7326
Merge 0.12->trunk
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Fri, 17 Feb 2023 17:02:41 +0000 |
parent | 12889:94a99330ce87 |
child | 12974:ba409c67353b |
child | 13378:db30ffbf2090 |
line wrap: on
line diff
--- a/net/http/parser.lua Thu Feb 16 20:15:39 2023 +0100 +++ b/net/http/parser.lua Fri Feb 17 17:02:41 2023 +0000 @@ -153,6 +153,7 @@ if not chunk_size then return; end chunk_size = chunk_size and tonumber(chunk_size, 16); if not chunk_size then error = true; return error_cb("invalid-chunk-size"); end + if chunk_size == 0 and chunk_header:find("\r\n\r\n", chunk_start-2, true) then local body_buffer = packet.body_buffer; if body_buffer then @@ -168,8 +169,8 @@ state, chunked = nil, nil; packet.partial = nil; success_cb(packet); - elseif buffer:length() - chunk_start - 2 >= chunk_size then -- we have a chunk - buffer:discard(chunk_start - 1); -- TODO verify that it's not off-by-one + elseif buffer:length() - chunk_start - 1 >= chunk_size then -- we have a chunk + buffer:discard(chunk_start - 1); (packet.body_sink or packet.body_buffer):write(buffer:read(chunk_size)); buffer:discard(2); -- CRLF else -- Partial chunk remaining