aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiego Nehab <diego@tecgraf.puc-rio.br>2003-03-28 22:41:26 +0000
committerDiego Nehab <diego@tecgraf.puc-rio.br>2003-03-28 22:41:26 +0000
commit4755ad727e36f2c3ad644718a2d477fffa9b1d23 (patch)
treecc24c7c87945cefd90521a509bc7526043895391
parent335cdbf334dde609c32cc46ad9536980066504f6 (diff)
downloadluasocket-4755ad727e36f2c3ad644718a2d477fffa9b1d23.tar.gz
luasocket-4755ad727e36f2c3ad644718a2d477fffa9b1d23.tar.bz2
luasocket-4755ad727e36f2c3ad644718a2d477fffa9b1d23.zip
Compiled in WinXP
-rw-r--r--test/httptest.lua42
1 files changed, 21 insertions, 21 deletions
diff --git a/test/httptest.lua b/test/httptest.lua
index 8b84f84..1eb4b6a 100644
--- a/test/httptest.lua
+++ b/test/httptest.lua
@@ -49,26 +49,26 @@ local request, response, ignore, expect, index, prefix, cgiprefix
49 49
50local t = socket._time() 50local t = socket._time()
51 51
52HOST = HOST or "localhost" 52host = host or "localhost"
53prefix = prefix or "/luasocket" 53prefix = prefix or "/luasocket"
54cgiprefix = cgiprefix or "/luasocket/cgi" 54cgiprefix = cgiprefix or "/luasocket/cgi"
55index = readfile("test/index.html") 55index = 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 = socket.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 = socket.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
69io.write("testing document retrieval: ") 69io.write("testing document retrieval: ")
70request = { 70request = {
71 url = "http://" .. HOST .. prefix .. "/index.html" 71 url = "http://" .. host .. prefix .. "/index.html"
72} 72}
73expect = { 73expect = {
74 body = index, 74 body = index,
@@ -82,7 +82,7 @@ check_request(request, expect, ignore)
82 82
83io.write("testing http redirection: ") 83io.write("testing http redirection: ")
84request = { 84request = {
85 url = "http://" .. HOST .. prefix 85 url = "http://" .. host .. prefix
86} 86}
87expect = { 87expect = {
88 body = index, 88 body = index,
@@ -97,7 +97,7 @@ check_request(request, expect, ignore)
97 97
98io.write("testing automatic auth failure: ") 98io.write("testing automatic auth failure: ")
99request = { 99request = {
100 url = "http://really:wrong@" .. HOST .. prefix .. "/auth/index.html" 100 url = "http://really:wrong@" .. host .. prefix .. "/auth/index.html"
101} 101}
102expect = { 102expect = {
103 code = 401 103 code = 401
@@ -111,7 +111,7 @@ check_request(request, expect, ignore)
111 111
112io.write("testing http redirection failure: ") 112io.write("testing http redirection failure: ")
113request = { 113request = {
114 url = "http://" .. HOST .. prefix, 114 url = "http://" .. host .. prefix,
115 stay = 1 115 stay = 1
116} 116}
117expect = { 117expect = {
@@ -137,7 +137,7 @@ check_request(request, expect, ignore)
137 137
138io.write("testing invalid url: ") 138io.write("testing invalid url: ")
139request = { 139request = {
140 url = HOST .. prefix 140 url = host .. prefix
141} 141}
142local c, e = socket.connect("", 80) 142local c, e = socket.connect("", 80)
143expect = { 143expect = {
@@ -148,7 +148,7 @@ check_request(request, expect, ignore)
148 148
149io.write("testing document not found: ") 149io.write("testing document not found: ")
150request = { 150request = {
151 url = "http://" .. HOST .. "/wrongdocument.html" 151 url = "http://" .. host .. "/wrongdocument.html"
152} 152}
153expect = { 153expect = {
154 code = 404 154 code = 404
@@ -162,7 +162,7 @@ check_request(request, expect, ignore)
162 162
163io.write("testing auth failure: ") 163io.write("testing auth failure: ")
164request = { 164request = {
165 url = "http://" .. HOST .. prefix .. "/auth/index.html" 165 url = "http://" .. host .. prefix .. "/auth/index.html"
166} 166}
167expect = { 167expect = {
168 code = 401 168 code = 401
@@ -176,7 +176,7 @@ check_request(request, expect, ignore)
176 176
177io.write("testing manual basic auth: ") 177io.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 " .. socket.code.base64("luasocket:password") 181 authorization = "Basic " .. socket.code.base64("luasocket:password")
182 } 182 }
@@ -193,7 +193,7 @@ check_request(request, expect, ignore)
193 193
194io.write("testing automatic basic auth: ") 194io.write("testing automatic basic auth: ")
195request = { 195request = {
196 url = "http://luasocket:password@" .. HOST .. prefix .. "/auth/index.html" 196 url = "http://luasocket:password@" .. host .. prefix .. "/auth/index.html"
197} 197}
198expect = { 198expect = {
199 code = 200, 199 code = 200,
@@ -207,7 +207,7 @@ check_request(request, expect, ignore)
207 207
208io.write("testing auth info overriding: ") 208io.write("testing auth info overriding: ")
209request = { 209request = {
210 url = "http://really:wrong@" .. HOST .. prefix .. "/auth/index.html", 210 url = "http://really:wrong@" .. host .. prefix .. "/auth/index.html",
211 user = "luasocket", 211 user = "luasocket",
212 password = "password" 212 password = "password"
213} 213}
@@ -223,7 +223,7 @@ check_request(request, expect, ignore)
223 223
224io.write("testing cgi output retrieval (probably chunked...): ") 224io.write("testing cgi output retrieval (probably chunked...): ")
225request = { 225request = {
226 url = "http://" .. HOST .. cgiprefix .. "/cat-index-html" 226 url = "http://" .. host .. cgiprefix .. "/cat-index-html"
227} 227}
228expect = { 228expect = {
229 body = index, 229 body = index,
@@ -237,7 +237,7 @@ check_request(request, expect, ignore)
237 237
238io.write("testing redirect loop: ") 238io.write("testing redirect loop: ")
239request = { 239request = {
240 url = "http://" .. HOST .. cgiprefix .. "/redirect-loop" 240 url = "http://" .. host .. cgiprefix .. "/redirect-loop"
241} 241}
242expect = { 242expect = {
243 code = 302 243 code = 302
@@ -251,7 +251,7 @@ check_request(request, expect, ignore)
251 251
252io.write("testing post method: ") 252io.write("testing post method: ")
253request = { 253request = {
254 url = "http://" .. HOST .. cgiprefix .. "/cat", 254 url = "http://" .. host .. cgiprefix .. "/cat",
255 method = "POST", 255 method = "POST",
256 body = index 256 body = index
257} 257}
@@ -267,7 +267,7 @@ check_request(request, expect, ignore)
267 267
268io.write("testing wrong scheme: ") 268io.write("testing wrong scheme: ")
269request = { 269request = {
270 url = "wrong://" .. HOST .. cgiprefix .. "/cat", 270 url = "wrong://" .. host .. cgiprefix .. "/cat",
271 method = "GET" 271 method = "GET"
272} 272}
273expect = { 273expect = {
@@ -279,24 +279,24 @@ check_request(request, expect, ignore)
279 279
280local body 280local body
281io.write("testing simple get function: ") 281io.write("testing simple get function: ")
282body = socket.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 = socket.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"
290} 290}
291check(body == index) 291check(body == index)
292 292
293io.write("testing simple post function: ") 293io.write("testing simple post function: ")
294body = socket.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 = socket.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)