summaryrefslogtreecommitdiffstats
path: root/test/httptest.lua
diff options
context:
space:
mode:
Diffstat (limited to 'test/httptest.lua')
-rwxr-xr-xtest/httptest.lua15
1 files changed, 9 insertions, 6 deletions
diff --git a/test/httptest.lua b/test/httptest.lua
index 85d21d1..1e88f28 100755
--- a/test/httptest.lua
+++ b/test/httptest.lua
@@ -27,22 +27,23 @@ local concat = table.concat
local done = false
utils.spawn(function()
- --local istream, ostream = assert(io.tcp_connect('www.google.dk', 80))
- local istream, ostream = assert(io.tcp_connect('127.0.0.1', 8080))
+ local conn = assert(io.tcp_connect('www.google.dk', 80))
+ --local conn = assert(io.tcp_connect('127.0.0.1', 8080))
print('\nConnected.')
for i = 1, 2 do
- --assert(ostream:write('GET / HTTP/1.1\r\nHost: www.google.dk\r\nConnection: close\r\n\r\n'))
- assert(ostream:write('GET / HTTP/1.1\r\nHost: www.google.dk\r\n\r\n'))
+ --assert(conn:write('GET / HTTP/1.1\r\nHost: www.google.dk\r\nConnection: close\r\n\r\n'))
+ assert(conn:write('GET / HTTP/1.1\r\nHost: www.google.dk\r\n\r\n'))
- local res = assert(istream:read('HTTPResponse'))
+ local res = assert(conn:read('HTTPResponse'))
print(format('\nHTTP/%s %d %s', res.version, res.status, res.text))
for k, v in pairs(res.headers) do
print(format('%s: %s', k, v))
end
+ --print(format('\n#body = %d', #assert(conn:read('*a'))))
print(format('\n#body = %d', #assert(res:body())))
end
@@ -50,9 +51,11 @@ utils.spawn(function()
end)
local write, yield = io.write, utils.yield
+local sleeper = utils.newsleeper()
repeat
write('.')
- yield()
+ --yield()
+ sleeper:sleep(0.001)
until done
-- vim: set ts=2 sw=2 noet: