Diff

net/http/parser.lua @ 7636:7674cb520557

Merge 0.10->trunk
author Kim Alvefur <zash@zash.se>
date Fri, 26 Aug 2016 16:57:53 +0200
parent 7635:6879a220917b
child 8045:55a56dc935f2
line wrap: on
line diff
--- a/net/http/parser.lua	Wed Aug 24 15:58:16 2016 +0200
+++ b/net/http/parser.lua	Fri Aug 26 16:57:53 2016 +0200
@@ -134,6 +134,9 @@
 				if state then -- read body
 					if client then
 						if chunked then
+							if chunk_start and buflen - chunk_start - 2 < chunk_size then
+								return;
+							end -- not enough data
 							if buftable then buf, buftable = t_concat(buf), false; end
 							if not buf:find("\r\n", nil, true) then
 								return;
@@ -150,6 +153,7 @@
 							elseif buflen - 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);
+								buflen = buflen - (chunk_start + chunk_size + 2 - 1);
 								chunk_size, chunk_start = nil, nil;
 							else -- Partial chunk remaining
 								break;