From eadd8212168e903344f94d53c5762095cb9be8f5 Mon Sep 17 00:00:00 2001
From: daurnimator <quae@daurnimator.com>
Date: Mon, 10 Nov 2014 14:47:33 -0500
Subject: net.http.parser: Fix chunked encoding parsing across packet
 boundaries.

---
 net/http/parser.lua | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'net')

diff --git a/net/http/parser.lua b/net/http/parser.lua
index d896dff4..056d4b60 100644
--- a/net/http/parser.lua
+++ b/net/http/parser.lua
@@ -132,7 +132,7 @@ function httpstream.new(success_cb, error_cb, parser_type, options_cb)
 								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;
-- 
cgit v1.2.3