Diff

net/http/parser.lua @ 7634:b1132d74f54c

net.http.parser: Fix missing buffer length adjustment when parsing chunked streams
author Kim Alvefur <zash@zash.se>
date Fri, 26 Aug 2016 16:39:04 +0200
parent 7581:01d0d466d7be
child 7635:6879a220917b
line wrap: on
line diff
--- a/net/http/parser.lua	Fri Apr 17 12:03:15 2015 +0200
+++ b/net/http/parser.lua	Fri Aug 26 16:39:04 2016 +0200
@@ -150,6 +150,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;