util.encodings: Spell out all IDNA 2008 options ICU has
[prosody.git] / spec / net_http_parser_spec.lua
blob6bba087cece778edc915da74ad56b718518b76a2
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
32 local http_parser = require "net.http.parser";
34 describe("net.http.parser", function()
35 describe("#new()", function()
36 it("should work", function()
37 for _, stream in ipairs(httpstreams) do
38 local success;
39 local function success_cb(packet)
40 success = true;
41 end
42 stream = stream:gsub("\n", "\r\n");
43 local parser = http_parser.new(success_cb, error, stream:sub(1,4) == "HTTP" and "client" or "server")
44 for chunk in stream:gmatch("..?.?") do
45 parser:feed(chunk);
46 end
48 assert.is_true(success);
49 end
50 end);
51 end);
52 end);