# HG changeset patch # User Kim Alvefur # Date 1416492052 -3600 # Node ID 185817ef4a4defffc50d66d5d0aa06d64e6acd01 # Parent 29c7586665f571363ff96264aeb5ab6dd9ecb321# Parent 63d3126b75f1924fe61791ae1c49c4aa326cb2c6 Merge 0.9->0.10 diff -r 29c7586665f5 -r 185817ef4a4d net/http/parser.lua --- a/net/http/parser.lua Wed Nov 19 14:47:49 2014 +0100 +++ b/net/http/parser.lua Thu Nov 20 15:00:52 2014 +0100 @@ -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; @@ -140,11 +140,11 @@ break; end elseif len and #buf >= len then - if packet.code == 101 then - packet.body, buf = buf, "" - else - packet.body, buf = buf:sub(1, len), buf:sub(len + 1); - end + if packet.code == 101 then + packet.body, buf = buf, ""; + else + packet.body, buf = buf:sub(1, len), buf:sub(len + 1); + end state = nil; success_cb(packet); else break;