-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.htm
41 lines (41 loc) · 1.24 KB
/
test.htm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?lua
local greeting = "hello, world\n"
put(greeting)
if rawrequest() ~= "GET /static/test.htm?a=b&b=c HTTP/1.0\r\n" ..
"Content-Length: 17\r\n" ..
"Host: localhost:1234\r\n" ..
"\r\n" ..
"foo=bar&test=test" then
error("rawrequest() didn't match with unit test value")
end
if method() ~= "GET" then
error("method() didn't match with unit test value")
end
if uri() ~= "/static/test.htm?a=b&b=c" then
error("uri() didn't match with unit test value")
end
if path() ~= "/static/test.htm?a=b&b=c" then
error("path() didn't match with unit test value")
end
if version() ~= "HTTP/1.0" then
error("version() didn't match with unit test value")
end
local headers = headers()
if headers["Host"] ~= "localhost:1234" then
error("headers() didn't match with unit test value")
end
if body() ~= "foo=bar&test=test" then
error("body() didn't match with unit test value")
end
local get = get()
if get["a"] ~= "b" or get["b"] ~= "c" then
error("get() didn't match with unit test value")
end
local post = post()
if post["foo"] ~= "bar" or post["test"] ~= "test" then
error("post() didn't match with unit test value")
end
addheader("Foo", "bar")
setstatus(202)
?>
<%= greeting %>