diff options
author | Diego Nehab <diego@tecgraf.puc-rio.br> | 2003-03-20 00:24:44 +0000 |
---|---|---|
committer | Diego Nehab <diego@tecgraf.puc-rio.br> | 2003-03-20 00:24:44 +0000 |
commit | 53857360bb1ca9cd2080b69d930763ae59db9b06 (patch) | |
tree | 6c1bc6d6462695cf9048801b2244f7fd0cd21ad5 /test/httptest.lua | |
parent | 7da19138e37c4e0123860f1fecbceb80c3d2627d (diff) | |
download | luasocket-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.lua | 18 |
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) | |||
31 | end | 31 | end |
32 | 32 | ||
33 | local check_request = function(request, expect, ignore) | 33 | local 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 | ||
57 | io.write("testing request uri correctness: ") | 57 | io.write("testing request uri correctness: ") |
58 | local forth = cgiprefix .. "/request-uri?" .. "this+is+the+query+string" | 58 | local forth = cgiprefix .. "/request-uri?" .. "this+is+the+query+string" |
59 | local back = http.get("http://" .. HOST .. forth) | 59 | local back = socket.http.get("http://" .. HOST .. forth) |
60 | if similar(back, forth) then print("ok") | 60 | if similar(back, forth) then print("ok") |
61 | else fail("failed!") end | 61 | else fail("failed!") end |
62 | 62 | ||
63 | io.write("testing query string correctness: ") | 63 | io.write("testing query string correctness: ") |
64 | forth = "this+is+the+query+string" | 64 | forth = "this+is+the+query+string" |
65 | back = http.get("http://" .. HOST .. cgiprefix .. "/query-string?" .. forth) | 65 | back = socket.http.get("http://" .. HOST .. cgiprefix .. "/query-string?" .. forth) |
66 | if similar(back, forth) then print("ok") | 66 | if similar(back, forth) then print("ok") |
67 | else fail("failed!") end | 67 | else fail("failed!") end |
68 | 68 | ||
@@ -178,7 +178,7 @@ io.write("testing manual basic auth: ") | |||
178 | request = { | 178 | request = { |
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 | } |
184 | expect = { | 184 | expect = { |
@@ -279,11 +279,11 @@ check_request(request, expect, ignore) | |||
279 | 279 | ||
280 | local body | 280 | local body |
281 | io.write("testing simple get function: ") | 281 | io.write("testing simple get function: ") |
282 | body = http.get("http://" .. HOST .. prefix .. "/index.html") | 282 | body = socket.http.get("http://" .. HOST .. prefix .. "/index.html") |
283 | check(body == index) | 283 | check(body == index) |
284 | 284 | ||
285 | io.write("testing simple get function with table args: ") | 285 | io.write("testing simple get function with table args: ") |
286 | body = http.get { | 286 | body = 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 { | |||
291 | check(body == index) | 291 | check(body == index) |
292 | 292 | ||
293 | io.write("testing simple post function: ") | 293 | io.write("testing simple post function: ") |
294 | body = http.post("http://" .. HOST .. cgiprefix .. "/cat", index) | 294 | body = socket.http.post("http://" .. HOST .. cgiprefix .. "/cat", index) |
295 | check(body == index) | 295 | check(body == index) |
296 | 296 | ||
297 | io.write("testing simple post function with table args: ") | 297 | io.write("testing simple post function with table args: ") |
298 | body = http.post { | 298 | body = socket.http.post { |
299 | url = "http://" .. HOST .. cgiprefix .. "/cat", | 299 | url = "http://" .. HOST .. cgiprefix .. "/cat", |
300 | body = index | 300 | body = index |
301 | } | 301 | } |
302 | check(body == index) | 302 | check(body == index) |
303 | 303 | ||
304 | io.write("testing HEAD method: ") | 304 | io.write("testing HEAD method: ") |
305 | response = http.request { | 305 | response = 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 | } |