X-Git-Url: https://git.enpas.org/?a=blobdiff_plain;f=net%2Fhttp%2Fparser.lua;h=6d7187da1920bf442142ec9730dff3d96db20ee6;hb=HEAD;hp=9688e0520a61173a7eec27e920d6fc36fb977aca;hpb=86ceb9a18c7bdc03ac889d96c15f5aed59ab5de6;p=prosody.git diff --git a/net/http/parser.lua b/net/http/parser.lua index 9688e052..6d7187da 100644 --- a/net/http/parser.lua +++ b/net/http/parser.lua @@ -132,8 +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 - print(chunk_start, chunk_size, ("%q"):format(buf)) + 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; @@ -141,7 +140,11 @@ function httpstream.new(success_cb, error_cb, parser_type, options_cb) break; end elseif len and #buf >= len then - packet.body, buf = buf:sub(1, len), buf:sub(len + 1); + 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;