CHANGES: Update for release
[prosody.git] / tests / test_net_http_parser.lua
blob1157b5ac33fa61d188d524bfe61710a88269cb86
1 local httpstreams = { [[
2 GET / HTTP/1.1
3 Host: example.com
5 ]], [[
6 HTTP/1.1 200 OK
7 Content-Length: 0
9 ]], [[
10 HTTP/1.1 200 OK
11 Content-Length: 7
13 Hello
14 HTTP/1.1 200 OK
15 Transfer-Encoding: chunked
31 function new(new)
33 for _, stream in ipairs(httpstreams) do
34 local success;
35 local function success_cb(packet)
36 success = true;
37 end
38 stream = stream:gsub("\n", "\r\n");
39 local parser = new(success_cb, error, stream:sub(1,4) == "HTTP" and "client" or "server")
40 for chunk in stream:gmatch("..?.?") do
41 parser:feed(chunk);
42 end
44 assert_is(success);
45 end
47 end