aboutsummaryrefslogtreecommitdiff
path: root/test/httptest.lua
diff options
context:
space:
mode:
Diffstat (limited to 'test/httptest.lua')
-rw-r--r--test/httptest.lua15
1 files changed, 6 insertions, 9 deletions
diff --git a/test/httptest.lua b/test/httptest.lua
index 1eb4b6a..030974c 100644
--- a/test/httptest.lua
+++ b/test/httptest.lua
@@ -3,9 +3,6 @@
3-- needs ScriptAlias from /home/c/diego/tec/luasocket/test/cgi 3-- needs ScriptAlias from /home/c/diego/tec/luasocket/test/cgi
4-- to /luasocket-test-cgi 4-- to /luasocket-test-cgi
5-- needs AllowOverride AuthConfig on /home/c/diego/tec/luasocket/test/auth 5-- needs AllowOverride AuthConfig on /home/c/diego/tec/luasocket/test/auth
6
7dofile("noglobals.lua")
8
9local similar = function(s1, s2) 6local similar = function(s1, s2)
10 return string.lower(string.gsub(s1 or "", "%s", "")) == 7 return string.lower(string.gsub(s1 or "", "%s", "")) ==
11 string.lower(string.gsub(s2 or "", "%s", "")) 8 string.lower(string.gsub(s2 or "", "%s", ""))
@@ -27,27 +24,27 @@ end
27 24
28local check = function (v, e) 25local check = function (v, e)
29 if v then print("ok") 26 if v then print("ok")
30 else %fail(e) end 27 else fail(e) end
31end 28end
32 29
33local check_request = function(request, expect, ignore) 30local check_request = function(request, expect, ignore)
34 local response = socket.http.request(request) 31 local response = socket.http.request(request)
35 for i,v in response do 32 for i,v in response do
36 if not ignore[i] then 33 if not ignore[i] then
37 if v ~= expect[i] then %fail(i .. " differs!") end 34 if v ~= expect[i] then fail(i .. " differs!") end
38 end 35 end
39 end 36 end
40 for i,v in expect do 37 for i,v in expect do
41 if not ignore[i] then 38 if not ignore[i] then
42 if v ~= response[i] then %fail(i .. " differs!") end 39 if v ~= response[i] then fail(i .. " differs!") end
43 end 40 end
44 end 41 end
45 print("ok") 42 print("ok")
46end 43end
47 44
48local request, response, ignore, expect, index, prefix, cgiprefix 45local host, request, response, ignore, expect, index, prefix, cgiprefix
49 46
50local t = socket._time() 47local t = socket.time()
51 48
52host = host or "localhost" 49host = host or "localhost"
53prefix = prefix or "/luasocket" 50prefix = prefix or "/luasocket"
@@ -310,4 +307,4 @@ check(response and response.headers)
310 307
311print("passed all tests") 308print("passed all tests")
312 309
313print(string.format("done in %.2fs", socket._time() - t)) 310print(string.format("done in %.2fs", socket.time() - t))