net.http.parser: Fix chunked encoding parsing across packet boundaries.
authordaurnimator <quae@daurnimator.com>
Mon, 10 Nov 2014 14:47:33 -0500
changeset 6525 46cf369d3eb5
parent 6512 7cb69eba3e95
child 6526 63d3126b75f1
net.http.parser: Fix chunked encoding parsing across packet boundaries.
net/http/parser.lua
--- a/net/http/parser.lua	Thu Oct 30 12:28:07 2014 +0100
+++ b/net/http/parser.lua	Mon Nov 10 14:47:33 2014 -0500
@@ -132,7 +132,7 @@
 								state, chunk_size = nil, nil;
 								buf = buf:gsub("^.-\r\n\r\n", ""); -- This ensure extensions and trailers are stripped
 								success_cb(packet);
-							elseif #buf - chunk_start + 2 >= chunk_size then -- we have a chunk
+							elseif #buf - chunk_start - 2 >= chunk_size then -- we have a chunk
 								packet.body = packet.body..buf:sub(chunk_start, chunk_start + (chunk_size-1));
 								buf = buf:sub(chunk_start + chunk_size + 2);
 								chunk_size, chunk_start = nil, nil;