Sun, 03 Jan 2016 17:30:35 +0000
net.http.parser: Support success_on_chunk when chunked encoding isn't being used (i.e. streaming mode)
net/http/parser.lua | file | annotate | diff | comparison | revisions |
--- a/net/http/parser.lua Thu Dec 25 10:48:06 2014 +0000 +++ b/net/http/parser.lua Sun Jan 03 17:30:35 2016 +0000 @@ -146,12 +146,17 @@ 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); + elseif success_on_chunk then + packet.partial = true; + packet.body = buf; + success_cb(packet); + buf = packet.body; else break; end