aboutsummaryrefslogtreecommitdiff
path: root/test/httptest.lua
diff options
context:
space:
mode:
authorDiego Nehab <diego@tecgraf.puc-rio.br>2003-03-20 00:24:44 +0000
committerDiego Nehab <diego@tecgraf.puc-rio.br>2003-03-20 00:24:44 +0000
commit53857360bb1ca9cd2080b69d930763ae59db9b06 (patch)
tree6c1bc6d6462695cf9048801b2244f7fd0cd21ad5 /test/httptest.lua
parent7da19138e37c4e0123860f1fecbceb80c3d2627d (diff)
downloadluasocket-53857360bb1ca9cd2080b69d930763ae59db9b06.tar.gz
luasocket-53857360bb1ca9cd2080b69d930763ae59db9b06.tar.bz2
luasocket-53857360bb1ca9cd2080b69d930763ae59db9b06.zip
Finish port to Lua 5. Everything is working fine.
Still doesn't work in Windows.
Diffstat (limited to 'test/httptest.lua')
-rw-r--r--test/httptest.lua18
1 files changed, 9 insertions, 9 deletions
diff --git a/test/httptest.lua b/test/httptest.lua
index 2941390..8b84f84 100644
--- a/test/httptest.lua
+++ b/test/httptest.lua
@@ -31,7 +31,7 @@ local check = function (v, e)
31end 31end
32 32
33local check_request = function(request, expect, ignore) 33local check_request = function(request, expect, ignore)
34 local response = http.request(request) 34 local response = socket.http.request(request)
35 for i,v in response do 35 for i,v in response do
36 if not ignore[i] then 36 if not ignore[i] then
37 if v ~= expect[i] then %fail(i .. " differs!") end 37 if v ~= expect[i] then %fail(i .. " differs!") end
@@ -56,13 +56,13 @@ index = readfile("test/index.html")
56 56
57io.write("testing request uri correctness: ") 57io.write("testing request uri correctness: ")
58local forth = cgiprefix .. "/request-uri?" .. "this+is+the+query+string" 58local forth = cgiprefix .. "/request-uri?" .. "this+is+the+query+string"
59local back = http.get("http://" .. HOST .. forth) 59local back = socket.http.get("http://" .. HOST .. forth)
60if similar(back, forth) then print("ok") 60if similar(back, forth) then print("ok")
61else fail("failed!") end 61else fail("failed!") end
62 62
63io.write("testing query string correctness: ") 63io.write("testing query string correctness: ")
64forth = "this+is+the+query+string" 64forth = "this+is+the+query+string"
65back = http.get("http://" .. HOST .. cgiprefix .. "/query-string?" .. forth) 65back = socket.http.get("http://" .. HOST .. cgiprefix .. "/query-string?" .. forth)
66if similar(back, forth) then print("ok") 66if similar(back, forth) then print("ok")
67else fail("failed!") end 67else fail("failed!") end
68 68
@@ -178,7 +178,7 @@ io.write("testing manual basic auth: ")
178request = { 178request = {
179 url = "http://" .. HOST .. prefix .. "/auth/index.html", 179 url = "http://" .. HOST .. prefix .. "/auth/index.html",
180 headers = { 180 headers = {
181 authorization = "Basic " .. Code.base64("luasocket:password") 181 authorization = "Basic " .. socket.code.base64("luasocket:password")
182 } 182 }
183} 183}
184expect = { 184expect = {
@@ -279,11 +279,11 @@ check_request(request, expect, ignore)
279 279
280local body 280local body
281io.write("testing simple get function: ") 281io.write("testing simple get function: ")
282body = http.get("http://" .. HOST .. prefix .. "/index.html") 282body = socket.http.get("http://" .. HOST .. prefix .. "/index.html")
283check(body == index) 283check(body == index)
284 284
285io.write("testing simple get function with table args: ") 285io.write("testing simple get function with table args: ")
286body = http.get { 286body = socket.http.get {
287 url = "http://really:wrong@" .. HOST .. prefix .. "/auth/index.html", 287 url = "http://really:wrong@" .. HOST .. prefix .. "/auth/index.html",
288 user = "luasocket", 288 user = "luasocket",
289 password = "password" 289 password = "password"
@@ -291,18 +291,18 @@ body = http.get {
291check(body == index) 291check(body == index)
292 292
293io.write("testing simple post function: ") 293io.write("testing simple post function: ")
294body = http.post("http://" .. HOST .. cgiprefix .. "/cat", index) 294body = socket.http.post("http://" .. HOST .. cgiprefix .. "/cat", index)
295check(body == index) 295check(body == index)
296 296
297io.write("testing simple post function with table args: ") 297io.write("testing simple post function with table args: ")
298body = http.post { 298body = socket.http.post {
299 url = "http://" .. HOST .. cgiprefix .. "/cat", 299 url = "http://" .. HOST .. cgiprefix .. "/cat",
300 body = index 300 body = index
301} 301}
302check(body == index) 302check(body == index)
303 303
304io.write("testing HEAD method: ") 304io.write("testing HEAD method: ")
305response = http.request { 305response = socket.http.request {
306 method = "HEAD", 306 method = "HEAD",
307 url = "http://www.tecgraf.puc-rio.br/~diego/" 307 url = "http://www.tecgraf.puc-rio.br/~diego/"
308} 308}