aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaleb Maclennan <caleb@alerque.com>2022-03-19 17:42:53 +0300
committerGitHub <noreply@github.com>2022-03-19 17:42:53 +0300
commita36818d3f3afd8758ec10991a5cb08ebdaca6329 (patch)
tree445c27832ac4fb48a03c146fa7c797dc4880c099
parent6952262e6a1315b14935ddd0ea511c202c0154ba (diff)
parent8390d07774a1ba1a597d809a1a2562d88ecce19d (diff)
downloadluasocket-a36818d3f3afd8758ec10991a5cb08ebdaca6329.tar.gz
luasocket-a36818d3f3afd8758ec10991a5cb08ebdaca6329.tar.bz2
luasocket-a36818d3f3afd8758ec10991a5cb08ebdaca6329.zip
Merge pull request #354 from lunarmodules/linter
-rw-r--r--.editorconfig23
-rw-r--r--.github/workflows/luacheck.yml19
-rw-r--r--.luacheckrc31
-rw-r--r--etc/cookie.lua22
-rw-r--r--etc/get.lua2
-rw-r--r--gem/ex11.lua4
-rw-r--r--gem/ex3.lua2
-rw-r--r--gem/ex4.lua2
-rw-r--r--samples/cddb.lua2
-rw-r--r--src/ftp.lua14
-rw-r--r--src/http.lua11
-rw-r--r--src/ltn12.lua3
-rw-r--r--src/mbox.lua13
-rw-r--r--src/mime.lua12
-rw-r--r--src/url.lua6
-rw-r--r--test/ltn12test.lua24
-rw-r--r--test/mimetest.lua46
-rw-r--r--test/smtptest.lua20
-rw-r--r--test/test_socket_error.lua2
-rw-r--r--test/testmesg.lua14
-rw-r--r--test/testsupport.lua2
-rw-r--r--test/urltest.lua114
-rw-r--r--test/utestclnt.lua68
-rw-r--r--test/utestsrvr.lua2
24 files changed, 260 insertions, 198 deletions
diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..56ad87d
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,23 @@
1root = true
2
3[*]
4end_of_line = lf
5insert_final_newline = true
6trim_trailing_whitespace = true
7charset = utf-8
8
9[{*.lua,*.rockspec,.luacheckrc}]
10indent_style = space
11indent_size = 4
12
13[Makefile]
14indent_style = tab
15indent_size = 4
16
17[*.html]
18indent_style = space
19indent_size = 4
20
21[*.{c,h}]
22indent_style = space
23indent_size = 4
diff --git a/.github/workflows/luacheck.yml b/.github/workflows/luacheck.yml
new file mode 100644
index 0000000..597cd64
--- /dev/null
+++ b/.github/workflows/luacheck.yml
@@ -0,0 +1,19 @@
1name: Luacheck
2
3on: [push, pull_request]
4
5jobs:
6
7 luacheck:
8 runs-on: ubuntu-20.04
9 steps:
10 - name: Checkout
11 uses: actions/checkout@v3
12 - name: Setup ‘lua’
13 uses: leafo/gh-actions-lua@v9
14 - name: Setup ‘luarocks’
15 uses: leafo/gh-actions-luarocks@v4
16 - name: Setup ‘luacheck’
17 run: luarocks install luacheck
18 - name: Run ‘luacheck’ linter
19 run: luacheck .
diff --git a/.luacheckrc b/.luacheckrc
new file mode 100644
index 0000000..8b25dd7
--- /dev/null
+++ b/.luacheckrc
@@ -0,0 +1,31 @@
1unused_args = false
2redefined = false
3max_line_length = false
4
5not_globals = {
6 "string.len",
7 "table.getn",
8}
9
10include_files = {
11 "**/*.lua",
12 "**/*.rockspec",
13 ".busted",
14 ".luacheckrc",
15}
16
17exclude_files = {
18 "etc/*.lua",
19 "etc/**/*.lua",
20 "test/*.lua",
21 "test/**/*.lua",
22 "samples/*.lua",
23 "samples/**/*.lua",
24 "gem/*.lua",
25 "gem/**/*.lua",
26 -- GH Actions Lua Environment
27 ".lua",
28 ".luarocks",
29 ".install",
30}
31
diff --git a/etc/cookie.lua b/etc/cookie.lua
index 4adb403..fec10a1 100644
--- a/etc/cookie.lua
+++ b/etc/cookie.lua
@@ -5,7 +5,7 @@ local ltn12 = require"ltn12"
5 5
6local token_class = '[^%c%s%(%)%<%>%@%,%;%:%\\%"%/%[%]%?%=%{%}]' 6local token_class = '[^%c%s%(%)%<%>%@%,%;%:%\\%"%/%[%]%?%=%{%}]'
7 7
8local function unquote(t, quoted) 8local function unquote(t, quoted)
9 local n = string.match(t, "%$(%d+)$") 9 local n = string.match(t, "%$(%d+)$")
10 if n then n = tonumber(n) end 10 if n then n = tonumber(n) end
11 if quoted[n] then return quoted[n] 11 if quoted[n] then return quoted[n]
@@ -14,19 +14,19 @@ end
14 14
15local function parse_set_cookie(c, quoted, cookie_table) 15local function parse_set_cookie(c, quoted, cookie_table)
16 c = c .. ";$last=last;" 16 c = c .. ";$last=last;"
17 local _, __, n, v, i = string.find(c, "(" .. token_class .. 17 local _, _, n, v, i = string.find(c, "(" .. token_class ..
18 "+)%s*=%s*(.-)%s*;%s*()") 18 "+)%s*=%s*(.-)%s*;%s*()")
19 local cookie = { 19 local cookie = {
20 name = n, 20 name = n,
21 value = unquote(v, quoted), 21 value = unquote(v, quoted),
22 attributes = {} 22 attributes = {}
23 } 23 }
24 while 1 do 24 while 1 do
25 _, __, n, v, i = string.find(c, "(" .. token_class .. 25 _, _, n, v, i = string.find(c, "(" .. token_class ..
26 "+)%s*=?%s*(.-)%s*;%s*()", i) 26 "+)%s*=?%s*(.-)%s*;%s*()", i)
27 if not n or n == "$last" then break end 27 if not n or n == "$last" then break end
28 cookie.attributes[#cookie.attributes+1] = { 28 cookie.attributes[#cookie.attributes+1] = {
29 name = n, 29 name = n,
30 value = unquote(v, quoted) 30 value = unquote(v, quoted)
31 } 31 }
32 end 32 end
@@ -46,8 +46,8 @@ local function split_set_cookie(s, cookie_table)
46 -- split into individual cookies 46 -- split into individual cookies
47 i = 1 47 i = 1
48 while 1 do 48 while 1 do
49 local _, __, cookie, next_token 49 local _, _, cookie, next_token
50 _, __, cookie, i, next_token = string.find(s, "(.-)%s*%,%s*()(" .. 50 _, _, cookie, i, next_token = string.find(s, "(.-)%s*%,%s*()(" ..
51 token_class .. "+)%s*=", i) 51 token_class .. "+)%s*=", i)
52 if not next_token then break end 52 if not next_token then break end
53 parse_set_cookie(cookie, quoted, cookie_table) 53 parse_set_cookie(cookie, quoted, cookie_table)
@@ -62,12 +62,12 @@ local function quote(s)
62end 62end
63 63
64local _empty = {} 64local _empty = {}
65local function build_cookies(cookies) 65local function build_cookies(cookies)
66 s = "" 66 s = ""
67 for i,v in ipairs(cookies or _empty) do 67 for i,v in ipairs(cookies or _empty) do
68 if v.name then 68 if v.name then
69 s = s .. v.name 69 s = s .. v.name
70 if v.value and v.value ~= "" then 70 if v.value and v.value ~= "" then
71 s = s .. '=' .. quote(v.value) 71 s = s .. '=' .. quote(v.value)
72 end 72 end
73 end 73 end
@@ -83,6 +83,6 @@ local function build_cookies(cookies)
83 end 83 end
84 if i < #cookies then s = s .. ", " end 84 if i < #cookies then s = s .. ", " end
85 end 85 end
86 return s 86 return s
87end 87end
88 88
diff --git a/etc/get.lua b/etc/get.lua
index 9edc235..d53c465 100644
--- a/etc/get.lua
+++ b/etc/get.lua
@@ -71,7 +71,7 @@ function stats(size)
71 local current = socket.gettime() 71 local current = socket.gettime()
72 if chunk then 72 if chunk then
73 -- total bytes received 73 -- total bytes received
74 got = got + string.len(chunk) 74 got = got + string.len(chunk)
75 -- not enough time for estimate 75 -- not enough time for estimate
76 if current - last > 1 then 76 if current - last > 1 then
77 io.stderr:write("\r", gauge(got, current - start, size)) 77 io.stderr:write("\r", gauge(got, current - start, size))
diff --git a/gem/ex11.lua b/gem/ex11.lua
index 1cbf01f..79c99af 100644
--- a/gem/ex11.lua
+++ b/gem/ex11.lua
@@ -1,7 +1,7 @@
1local input = source.chain( 1local input = source.chain(
2 source.file(io.open("input.bin", "rb")), 2 source.file(io.open("input.bin", "rb")),
3 encode("base64")) 3 encode("base64"))
4local output = sink.chain( 4local output = sink.chain(
5 wrap(76), 5 wrap(76),
6 sink.file(io.open("output.b64", "w"))) 6 sink.file(io.open("output.b64", "w")))
7pump.all(input, output) 7pump.all(input, output)
diff --git a/gem/ex3.lua b/gem/ex3.lua
index a43fefa..60b4423 100644
--- a/gem/ex3.lua
+++ b/gem/ex3.lua
@@ -7,7 +7,7 @@ local function chainpair(f1, f2)
7end 7end
8 8
9function filter.chain(...) 9function filter.chain(...)
10 local f = select(1, ...) 10 local f = select(1, ...)
11 for i = 2, select('#', ...) do 11 for i = 2, select('#', ...) do
12 f = chainpair(f, select(i, ...)) 12 f = chainpair(f, select(i, ...))
13 end 13 end
diff --git a/gem/ex4.lua b/gem/ex4.lua
index c670e0e..c48b77e 100644
--- a/gem/ex4.lua
+++ b/gem/ex4.lua
@@ -1,4 +1,4 @@
1local qp = filter.chain(normalize(CRLF), encode("quoted-printable"), 1local qp = filter.chain(normalize(CRLF), encode("quoted-printable"),
2 wrap("quoted-printable")) 2 wrap("quoted-printable"))
3local input = source.chain(source.file(io.stdin), qp) 3local input = source.chain(source.file(io.stdin), qp)
4local output = sink.file(io.stdout) 4local output = sink.file(io.stdout)
diff --git a/samples/cddb.lua b/samples/cddb.lua
index 49a1871..59d5a44 100644
--- a/samples/cddb.lua
+++ b/samples/cddb.lua
@@ -26,7 +26,7 @@ function parse(body)
26 data[key] = value 26 data[key] = value
27 end 27 end
28 end 28 end
29 return data, code, message 29 return data, code, message
30end 30end
31 31
32local host = socket.dns.gethostname() 32local host = socket.dns.gethostname()
diff --git a/src/ftp.lua b/src/ftp.lua
index bd528ca..0ebc508 100644
--- a/src/ftp.lua
+++ b/src/ftp.lua
@@ -56,7 +56,7 @@ end
56 56
57function metat.__index:login(user, password) 57function metat.__index:login(user, password)
58 self.try(self.tp:command("user", user or _M.USER)) 58 self.try(self.tp:command("user", user or _M.USER))
59 local code, reply = self.try(self.tp:check{"2..", 331}) 59 local code, _ = self.try(self.tp:check{"2..", 331})
60 if code == 331 then 60 if code == 331 then
61 self.try(self.tp:command("pass", password or _M.PASSWORD)) 61 self.try(self.tp:command("pass", password or _M.PASSWORD))
62 self.try(self.tp:check("2..")) 62 self.try(self.tp:check("2.."))
@@ -66,7 +66,7 @@ end
66 66
67function metat.__index:pasv() 67function metat.__index:pasv()
68 self.try(self.tp:command("pasv")) 68 self.try(self.tp:command("pasv"))
69 local code, reply = self.try(self.tp:check("2..")) 69 local _, reply = self.try(self.tp:check("2.."))
70 local pattern = "(%d+)%D(%d+)%D(%d+)%D(%d+)%D(%d+)%D(%d+)" 70 local pattern = "(%d+)%D(%d+)%D(%d+)%D(%d+)%D(%d+)%D(%d+)"
71 local a, b, c, d, p1, p2 = socket.skip(2, string.find(reply, pattern)) 71 local a, b, c, d, p1, p2 = socket.skip(2, string.find(reply, pattern))
72 self.try(a and b and c and d and p1 and p2, reply) 72 self.try(a and b and c and d and p1 and p2, reply)
@@ -83,9 +83,9 @@ end
83 83
84function metat.__index:epsv() 84function metat.__index:epsv()
85 self.try(self.tp:command("epsv")) 85 self.try(self.tp:command("epsv"))
86 local code, reply = self.try(self.tp:check("229")) 86 local _, reply = self.try(self.tp:check("229"))
87 local pattern = "%((.)(.-)%1(.-)%1(.-)%1%)" 87 local pattern = "%((.)(.-)%1(.-)%1(.-)%1%)"
88 local d, prt, address, port = string.match(reply, pattern) 88 local _, _, _, port = string.match(reply, pattern)
89 self.try(port, "invalid epsv response") 89 self.try(port, "invalid epsv response")
90 self.pasvt = { 90 self.pasvt = {
91 address = self.tp:getpeername(), 91 address = self.tp:getpeername(),
@@ -102,7 +102,7 @@ end
102function metat.__index:port(address, port) 102function metat.__index:port(address, port)
103 self.pasvt = nil 103 self.pasvt = nil
104 if not address then 104 if not address then
105 address, port = self.try(self.tp:getsockname()) 105 address = self.try(self.tp:getsockname())
106 self.server = self.try(socket.bind(address, 0)) 106 self.server = self.try(socket.bind(address, 0))
107 address, port = self.try(self.server:getsockname()) 107 address, port = self.try(self.server:getsockname())
108 self.try(self.server:settimeout(_M.TIMEOUT)) 108 self.try(self.server:settimeout(_M.TIMEOUT))
@@ -118,7 +118,7 @@ end
118function metat.__index:eprt(family, address, port) 118function metat.__index:eprt(family, address, port)
119 self.pasvt = nil 119 self.pasvt = nil
120 if not address then 120 if not address then
121 address, port = self.try(self.tp:getsockname()) 121 address = self.try(self.tp:getsockname())
122 self.server = self.try(socket.bind(address, 0)) 122 self.server = self.try(socket.bind(address, 0))
123 address, port = self.try(self.server:getsockname()) 123 address, port = self.try(self.server:getsockname())
124 self.try(self.server:settimeout(_M.TIMEOUT)) 124 self.try(self.server:settimeout(_M.TIMEOUT))
@@ -142,7 +142,7 @@ function metat.__index:send(sendt)
142 local command = sendt.command or "stor" 142 local command = sendt.command or "stor"
143 -- send the transfer command and check the reply 143 -- send the transfer command and check the reply
144 self.try(self.tp:command(command, argument)) 144 self.try(self.tp:command(command, argument))
145 local code, reply = self.try(self.tp:check{"2..", "1.."}) 145 local code, _ = self.try(self.tp:check{"2..", "1.."})
146 -- if there is not a pasvt table, then there is a server 146 -- if there is not a pasvt table, then there is a server
147 -- and we already sent a PORT command 147 -- and we already sent a PORT command
148 if not self.pasvt then self:portconnect() end 148 if not self.pasvt then self:portconnect() end
diff --git a/src/http.lua b/src/http.lua
index 6a3416e..e3a1742 100644
--- a/src/http.lua
+++ b/src/http.lua
@@ -41,9 +41,6 @@ local SCHEMES = {
41 https.tcp, 'LuaSocket: Function tcp() not available from LuaSec') 41 https.tcp, 'LuaSocket: Function tcp() not available from LuaSec')
42 return tcp(t) end }} 42 return tcp(t) end }}
43 43
44-- default scheme and port for document retrieval
45local SCHEME = 'http'
46local PORT = SCHEMES[SCHEME].port
47----------------------------------------------------------------------------- 44-----------------------------------------------------------------------------
48-- Reads MIME headers from a connection, unfolding where needed 45-- Reads MIME headers from a connection, unfolding where needed
49----------------------------------------------------------------------------- 46-----------------------------------------------------------------------------
@@ -92,7 +89,7 @@ socket.sourcet["http-chunked"] = function(sock, headers)
92 -- was it the last chunk? 89 -- was it the last chunk?
93 if size > 0 then 90 if size > 0 then
94 -- if not, get chunk and skip terminating CRLF 91 -- if not, get chunk and skip terminating CRLF
95 local chunk, err, part = sock:receive(size) 92 local chunk, err, _ = sock:receive(size)
96 if chunk then sock:receive() end 93 if chunk then sock:receive() end
97 return chunk, err 94 return chunk, err
98 else 95 else
@@ -166,8 +163,8 @@ function metat.__index:receivestatusline()
166 if status ~= "HTTP/" then 163 if status ~= "HTTP/" then
167 if ec == "timeout" then 164 if ec == "timeout" then
168 return 408 165 return 408
169 end 166 end
170 return nil, status 167 return nil, status
171 end 168 end
172 -- otherwise proceed reading a status line 169 -- otherwise proceed reading a status line
173 status = self.try(self.c:receive("*l", status)) 170 status = self.try(self.c:receive("*l", status))
@@ -366,7 +363,7 @@ end
366 local headers 363 local headers
367 -- ignore any 100-continue messages 364 -- ignore any 100-continue messages
368 while code == 100 do 365 while code == 100 do
369 headers = h:receiveheaders() 366 h:receiveheaders()
370 code, status = h:receivestatusline() 367 code, status = h:receivestatusline()
371 end 368 end
372 headers = h:receiveheaders() 369 headers = h:receiveheaders()
diff --git a/src/ltn12.lua b/src/ltn12.lua
index afa735d..f1e05e1 100644
--- a/src/ltn12.lua
+++ b/src/ltn12.lua
@@ -13,7 +13,7 @@ local unpack = unpack or table.unpack
13local base = _G 13local base = _G
14local _M = {} 14local _M = {}
15if module then -- heuristic for exporting a global package table 15if module then -- heuristic for exporting a global package table
16 ltn12 = _M 16 ltn12 = _M -- luacheck: ignore
17end 17end
18local filter,source,sink,pump = {},{},{},{} 18local filter,source,sink,pump = {},{},{},{}
19 19
@@ -23,7 +23,6 @@ _M.sink = sink
23_M.pump = pump 23_M.pump = pump
24 24
25local unpack = unpack or table.unpack 25local unpack = unpack or table.unpack
26local select = base.select
27 26
28-- 2048 seems to be better in windows... 27-- 2048 seems to be better in windows...
29_M.BLOCKSIZE = 2048 28_M.BLOCKSIZE = 2048
diff --git a/src/mbox.lua b/src/mbox.lua
index ed9e781..12823b0 100644
--- a/src/mbox.lua
+++ b/src/mbox.lua
@@ -1,8 +1,8 @@
1local _M = {} 1local _M = {}
2 2
3if module then 3if module then
4 mbox = _M 4 mbox = _M -- luacheck: ignore
5end 5end
6 6
7function _M.split_message(message_s) 7function _M.split_message(message_s)
8 local message = {} 8 local message = {}
@@ -29,7 +29,7 @@ end
29function _M.parse_header(header_s) 29function _M.parse_header(header_s)
30 header_s = string.gsub(header_s, "\n[ ]+", " ") 30 header_s = string.gsub(header_s, "\n[ ]+", " ")
31 header_s = string.gsub(header_s, "\n+", "") 31 header_s = string.gsub(header_s, "\n+", "")
32 local _, __, name, value = string.find(header_s, "([^%s:]-):%s*(.*)") 32 local _, _, name, value = string.find(header_s, "([^%s:]-):%s*(.*)")
33 return name, value 33 return name, value
34end 34end
35 35
@@ -49,9 +49,9 @@ function _M.parse_headers(headers_s)
49end 49end
50 50
51function _M.parse_from(from) 51function _M.parse_from(from)
52 local _, __, name, address = string.find(from, "^%s*(.-)%s*%<(.-)%>") 52 local _, _, name, address = string.find(from, "^%s*(.-)%s*%<(.-)%>")
53 if not address then 53 if not address then
54 _, __, address = string.find(from, "%s*(.+)%s*") 54 _, _, address = string.find(from, "%s*(.+)%s*")
55 end 55 end
56 name = name or "" 56 name = name or ""
57 address = address or "" 57 address = address or ""
@@ -63,7 +63,8 @@ end
63function _M.split_mbox(mbox_s) 63function _M.split_mbox(mbox_s)
64 local mbox = {} 64 local mbox = {}
65 mbox_s = string.gsub(mbox_s, "\r\n", "\n") .."\n\nFrom \n" 65 mbox_s = string.gsub(mbox_s, "\r\n", "\n") .."\n\nFrom \n"
66 local nj, i, j = 1, 1, 1 66 local nj, i
67 local j = 1
67 while 1 do 68 while 1 do
68 i, nj = string.find(mbox_s, "\n\nFrom .-\n", j) 69 i, nj = string.find(mbox_s, "\n\nFrom .-\n", j)
69 if not i then break end 70 if not i then break end
diff --git a/src/mime.lua b/src/mime.lua
index d3abac5..93539de 100644
--- a/src/mime.lua
+++ b/src/mime.lua
@@ -10,7 +10,6 @@
10local base = _G 10local base = _G
11local ltn12 = require("ltn12") 11local ltn12 = require("ltn12")
12local mime = require("mime.core") 12local mime = require("mime.core")
13local string = require("string")
14local _M = mime 13local _M = mime
15 14
16-- encode, decode and wrap algorithm tables 15-- encode, decode and wrap algorithm tables
@@ -18,7 +17,7 @@ local encodet, decodet, wrapt = {},{},{}
18 17
19_M.encodet = encodet 18_M.encodet = encodet
20_M.decodet = decodet 19_M.decodet = decodet
21_M.wrapt = wrapt 20_M.wrapt = wrapt
22 21
23-- creates a function that chooses a filter by name from a given table 22-- creates a function that chooses a filter by name from a given table
24local function choose(table) 23local function choose(table)
@@ -27,7 +26,7 @@ local function choose(table)
27 name, opt1, opt2 = "default", name, opt1 26 name, opt1, opt2 = "default", name, opt1
28 end 27 end
29 local f = table[name or "nil"] 28 local f = table[name or "nil"]
30 if not f then 29 if not f then
31 base.error("unknown key (" .. base.tostring(name) .. ")", 3) 30 base.error("unknown key (" .. base.tostring(name) .. ")", 3)
32 else return f(opt1, opt2) end 31 else return f(opt1, opt2) end
33 end 32 end
@@ -52,13 +51,6 @@ decodet['quoted-printable'] = function()
52 return ltn12.filter.cycle(_M.unqp, "") 51 return ltn12.filter.cycle(_M.unqp, "")
53end 52end
54 53
55local function format(chunk)
56 if chunk then
57 if chunk == "" then return "''"
58 else return string.len(chunk) end
59 else return "nil" end
60end
61
62-- define the line-wrap filters 54-- define the line-wrap filters
63wrapt['text'] = function(length) 55wrapt['text'] = function(length)
64 length = length or 76 56 length = length or 76
diff --git a/src/url.lua b/src/url.lua
index 0a3a80a..8e0dc5c 100644
--- a/src/url.lua
+++ b/src/url.lua
@@ -179,9 +179,9 @@ function _M.parse(url, default)
179 function(u) parsed.userinfo = u; return "" end) 179 function(u) parsed.userinfo = u; return "" end)
180 authority = string.gsub(authority, ":([^:%]]*)$", 180 authority = string.gsub(authority, ":([^:%]]*)$",
181 function(p) parsed.port = p; return "" end) 181 function(p) parsed.port = p; return "" end)
182 if authority ~= "" then 182 if authority ~= "" then
183 -- IPv6? 183 -- IPv6?
184 parsed.host = string.match(authority, "^%[(.+)%]$") or authority 184 parsed.host = string.match(authority, "^%[(.+)%]$") or authority
185 end 185 end
186 local userinfo = parsed.userinfo 186 local userinfo = parsed.userinfo
187 if not userinfo then return parsed end 187 if not userinfo then return parsed end
@@ -264,7 +264,7 @@ function _M.absolute(base_url, relative_url)
264 relative_parsed.query = base_parsed.query 264 relative_parsed.query = base_parsed.query
265 end 265 end
266 end 266 end
267 else 267 else
268 relative_parsed.path = absolute_path(base_parsed.path or "", 268 relative_parsed.path = absolute_path(base_parsed.path or "",
269 relative_parsed.path) 269 relative_parsed.path)
270 end 270 end
diff --git a/test/ltn12test.lua b/test/ltn12test.lua
index e7d368d..0cafbc9 100644
--- a/test/ltn12test.lua
+++ b/test/ltn12test.lua
@@ -38,7 +38,7 @@ local function named(f, name)
38end 38end
39 39
40-------------------------------- 40--------------------------------
41local function split(size) 41local function split(size)
42 local buffer = "" 42 local buffer = ""
43 local last_out = "" 43 local last_out = ""
44 local last_in = "" 44 local last_in = ""
@@ -50,12 +50,12 @@ local function split(size)
50 return last_out 50 return last_out
51 end 51 end
52 return function(chunk, done) 52 return function(chunk, done)
53 if done then 53 if done then
54 return not last_in and not last_out 54 return not last_in and not last_out
55 end 55 end
56 -- check if argument is consistent with state 56 -- check if argument is consistent with state
57 if not chunk then 57 if not chunk then
58 if last_in and last_in ~= "" and last_out ~= "" then 58 if last_in and last_in ~= "" and last_out ~= "" then
59 error("nil chunk following data chunk", 2) 59 error("nil chunk following data chunk", 2)
60 end 60 end
61 if not last_out then error("extra nil chunk", 2) end 61 if not last_out then error("extra nil chunk", 2) end
@@ -67,8 +67,8 @@ local function split(size)
67 return output(chunk) 67 return output(chunk)
68 else 68 else
69 if not last_in then error("data chunk following nil chunk", 2) end 69 if not last_in then error("data chunk following nil chunk", 2) end
70 if last_in ~= "" and last_out ~= "" then 70 if last_in ~= "" and last_out ~= "" then
71 error("data chunk following data chunk", 2) 71 error("data chunk following data chunk", 2)
72 end 72 end
73 buffer = chunk 73 buffer = chunk
74 return output(chunk) 74 return output(chunk)
@@ -85,7 +85,7 @@ local function format(chunk)
85end 85end
86 86
87-------------------------------- 87--------------------------------
88local function merge(size) 88local function merge(size)
89 local buffer = "" 89 local buffer = ""
90 local last_out = "" 90 local last_out = ""
91 local last_in = "" 91 local last_in = ""
@@ -102,12 +102,12 @@ local function merge(size)
102 return last_out 102 return last_out
103 end 103 end
104 return function(chunk, done) 104 return function(chunk, done)
105 if done then 105 if done then
106 return not last_in and not last_out 106 return not last_in and not last_out
107 end 107 end
108 -- check if argument is consistent with state 108 -- check if argument is consistent with state
109 if not chunk then 109 if not chunk then
110 if last_in and last_in ~= "" and last_out ~= "" then 110 if last_in and last_in ~= "" and last_out ~= "" then
111 error("nil chunk following data chunk", 2) 111 error("nil chunk following data chunk", 2)
112 end 112 end
113 if not last_out then error("extra nil chunk", 2) end 113 if not last_out then error("extra nil chunk", 2) end
@@ -119,8 +119,8 @@ local function merge(size)
119 return output(chunk) 119 return output(chunk)
120 else 120 else
121 if not last_in then error("data chunk following nil chunk", 2) end 121 if not last_in then error("data chunk following nil chunk", 2) end
122 if last_in ~= "" and last_out ~= "" then 122 if last_in ~= "" and last_out ~= "" then
123 error("data chunk following data chunk", 2) 123 error("data chunk following data chunk", 2)
124 end 124 end
125 buffer = buffer .. chunk 125 buffer = buffer .. chunk
126 return output(chunk) 126 return output(chunk)
diff --git a/test/mimetest.lua b/test/mimetest.lua
index f5b3747..a3c89ac 100644
--- a/test/mimetest.lua
+++ b/test/mimetest.lua
@@ -15,27 +15,27 @@ local eb64test = "b64test.bin2"
15local db64test = "b64test.bin3" 15local db64test = "b64test.bin3"
16 16
17 17
18-- from Machado de Assis, "A Mão e a Rosa" 18-- from Machado de Assis, "A M�o e a Rosa"
19local mao = [[ 19local mao = [[
20 Cursavam estes dois moços a academia de S. Paulo, estando 20 Cursavam estes dois mo�os a academia de S. Paulo, estando
21 Luís Alves no quarto ano e Estêvão no terceiro. 21 Lu�s Alves no quarto ano e Est�v�o no terceiro.
22 Conheceram-se na academia, e ficaram amigos íntimos, tanto 22 Conheceram-se na academia, e ficaram amigos �ntimos, tanto
23 quanto podiam sê-lo dois espíritos diferentes, ou talvez por 23 quanto podiam s�-lo dois esp�ritos diferentes, ou talvez por
24 isso mesmo que o eram. Estêvão, dotado de extrema 24 isso mesmo que o eram. Est�v�o, dotado de extrema
25 sensibilidade, e não menor fraqueza de ânimo, afetuoso e 25 sensibilidade, e n�o menor fraqueza de �nimo, afetuoso e
26 bom, não daquela bondade varonil, que é apanágio de uma alma 26 bom, n�o daquela bondade varonil, que � apan�gio de uma alma
27 forte, mas dessa outra bondade mole e de cera, que vai à 27 forte, mas dessa outra bondade mole e de cera, que vai �
28 mercê de todas as circunstâncias, tinha, além de tudo isso, 28 merc� de todas as circunst�ncias, tinha, al�m de tudo isso,
29 o infortúnio de trazer ainda sobre o nariz os óculos 29 o infort�nio de trazer ainda sobre o nariz os �culos
30 cor-de-rosa de suas virginais ilusões. Luís Alves via bem 30 cor-de-rosa de suas virginais ilus�es. Lu�s Alves via bem
31 com os olhos da cara. Não era mau rapaz, mas tinha o seu 31 com os olhos da cara. N�o era mau rapaz, mas tinha o seu
32 grão de egoísmo, e se não era incapaz de afeições, sabia 32 gr�o de ego�smo, e se n�o era incapaz de afei��es, sabia
33 regê-las, moderá-las, e sobretudo guiá-las ao seu próprio 33 reg�-las, moder�-las, e sobretudo gui�-las ao seu pr�prio
34 interesse. Entre estes dois homens travara-se amizade 34 interesse. Entre estes dois homens travara-se amizade
35 íntima, nascida para um na simpatia, para outro no costume. 35 �ntima, nascida para um na simpatia, para outro no costume.
36 Eram eles os naturais confidentes um do outro, com a 36 Eram eles os naturais confidentes um do outro, com a
37 diferença que Luís Alves dava menos do que recebia, e, ainda 37 diferen�a que Lu�s Alves dava menos do que recebia, e, ainda
38 assim, nem tudo o que dava exprimia grande confiança. 38 assim, nem tudo o que dava exprimia grande confian�a.
39]] 39]]
40 40
41local function random(handle, io_err) 41local function random(handle, io_err)
@@ -44,8 +44,8 @@ local function random(handle, io_err)
44 if not handle then error("source is empty!", 2) end 44 if not handle then error("source is empty!", 2) end
45 local len = math.random(0, 1024) 45 local len = math.random(0, 1024)
46 local chunk = handle:read(len) 46 local chunk = handle:read(len)
47 if not chunk then 47 if not chunk then
48 handle:close() 48 handle:close()
49 handle = nil 49 handle = nil
50 end 50 end
51 return chunk 51 return chunk
@@ -62,7 +62,7 @@ local what = nil
62local function transform(input, output, filter) 62local function transform(input, output, filter)
63 local source = random(io.open(input, "rb")) 63 local source = random(io.open(input, "rb"))
64 local sink = ltn12.sink.file(io.open(output, "wb")) 64 local sink = ltn12.sink.file(io.open(output, "wb"))
65 if what then 65 if what then
66 sink = ltn12.sink.chain(filter, sink) 66 sink = ltn12.sink.chain(filter, sink)
67 else 67 else
68 source = ltn12.source.chain(source, filter) 68 source = ltn12.source.chain(source, filter)
@@ -147,7 +147,7 @@ local function create_qptest()
147 f:write(' ',string.char(32)) 147 f:write(' ',string.char(32))
148 end 148 end
149 f:write("\r\n") 149 f:write("\r\n")
150 150
151 f:close() 151 f:close()
152end 152end
153 153
@@ -157,7 +157,7 @@ local function cleanup_qptest()
157 os.remove(dqptest) 157 os.remove(dqptest)
158end 158end
159 159
160-- create test file 160-- create test file
161local function create_b64test() 161local function create_b64test()
162 local f = assert(io.open(b64test, "wb")) 162 local f = assert(io.open(b64test, "wb"))
163 local t = {} 163 local t = {}
diff --git a/test/smtptest.lua b/test/smtptest.lua
index b5380ff..9d06054 100644
--- a/test/smtptest.lua
+++ b/test/smtptest.lua
@@ -27,8 +27,8 @@ local total = function()
27end 27end
28 28
29local similar = function(s1, s2) 29local similar = function(s1, s2)
30 return 30 return
31 string.lower(string.gsub(s1, "%s", "")) == 31 string.lower(string.gsub(s1, "%s", "")) ==
32 string.lower(string.gsub(s2, "%s", "")) 32 string.lower(string.gsub(s2, "%s", ""))
33end 33end
34 34
@@ -40,9 +40,9 @@ end
40 40
41local readfile = function(name) 41local readfile = function(name)
42 local f = io.open(name, "r") 42 local f = io.open(name, "r")
43 if not f then 43 if not f then
44 fail("unable to open file!") 44 fail("unable to open file!")
45 return nil 45 return nil
46 end 46 end
47 local s = f:read("*a") 47 local s = f:read("*a")
48 f:close() 48 f:close()
@@ -52,7 +52,7 @@ end
52local empty = function() 52local empty = function()
53 for i,v in ipairs(files) do 53 for i,v in ipairs(files) do
54 local f = io.open(v, "w") 54 local f = io.open(v, "w")
55 if not f then 55 if not f then
56 fail("unable to open file!") 56 fail("unable to open file!")
57 end 57 end
58 f:close() 58 f:close()
@@ -116,8 +116,8 @@ local wait = function(sentinel, n)
116 while 1 do 116 while 1 do
117 local mbox = parse(get()) 117 local mbox = parse(get())
118 if n == #mbox then break end 118 if n == #mbox then break end
119 if socket.time() - sentinel.time > 50 then 119 if socket.time() - sentinel.time > 50 then
120 to = 1 120 to = 1
121 break 121 break
122 end 122 end
123 socket.sleep(1) 123 socket.sleep(1)
@@ -132,7 +132,7 @@ local stuffed_body = [[
132This message body needs to be 132This message body needs to be
133stuffed because it has a dot 133stuffed because it has a dot
134. 134.
135by itself on a line. 135by itself on a line.
136Otherwise the mailer would 136Otherwise the mailer would
137think that the dot 137think that the dot
138. 138.
@@ -219,7 +219,7 @@ else print("ok") end
219 219
220io.write("testing invalid from: ") 220io.write("testing invalid from: ")
221local ret, err = socket.smtp.mail{ 221local ret, err = socket.smtp.mail{
222 from = ' " " (( _ * ', 222 from = ' " " (( _ * ',
223 rcpt = rcpt, 223 rcpt = rcpt,
224} 224}
225if ret or not err then fail("wrong error message") 225if ret or not err then fail("wrong error message")
@@ -227,7 +227,7 @@ else print(err) end
227 227
228io.write("testing no rcpt: ") 228io.write("testing no rcpt: ")
229local ret, err = socket.smtp.mail{ 229local ret, err = socket.smtp.mail{
230 from = from, 230 from = from,
231} 231}
232if ret or not err then fail("wrong error message") 232if ret or not err then fail("wrong error message")
233else print(err) end 233else print(err) end
diff --git a/test/test_socket_error.lua b/test/test_socket_error.lua
index bda6408..1b4b601 100644
--- a/test/test_socket_error.lua
+++ b/test/test_socket_error.lua
@@ -19,7 +19,7 @@ for i = 1, 10 do
19 assert(ss == sock) 19 assert(ss == sock)
20 else 20 else
21 assert('timeout' == err, 'unexpected error :' .. tostring(err)) 21 assert('timeout' == err, 'unexpected error :' .. tostring(err))
22 end 22 end
23 err = sock:getoption("error") -- i get 'connection refused' on WinXP 23 err = sock:getoption("error") -- i get 'connection refused' on WinXP
24 if err then 24 if err then
25 print("Passed! Error is '" .. err .. "'.") 25 print("Passed! Error is '" .. err .. "'.")
diff --git a/test/testmesg.lua b/test/testmesg.lua
index 135a008..8c086d5 100644
--- a/test/testmesg.lua
+++ b/test/testmesg.lua
@@ -34,11 +34,11 @@ r, e = smtp.send{
34 34
35print(r, e) 35print(r, e)
36 36
37-- creates a source to send a message with two parts. The first part is 37-- creates a source to send a message with two parts. The first part is
38-- plain text, the second part is a PNG image, encoded as base64. 38-- plain text, the second part is a PNG image, encoded as base64.
39source = smtp.message{ 39source = smtp.message{
40 headers = { 40 headers = {
41 -- Remember that headers are *ignored* by smtp.send. 41 -- Remember that headers are *ignored* by smtp.send.
42 from = "Sicrano <sicrano@tecgraf.puc-rio.br>", 42 from = "Sicrano <sicrano@tecgraf.puc-rio.br>",
43 to = "Fulano <fulano@tecgraf.puc-rio.br>", 43 to = "Fulano <fulano@tecgraf.puc-rio.br>",
44 subject = "Here is a message with attachments" 44 subject = "Here is a message with attachments"
@@ -49,18 +49,18 @@ source = smtp.message{
49 "Preamble might show up even in a MIME enabled client.", 49 "Preamble might show up even in a MIME enabled client.",
50 -- first part: No headers means plain text, us-ascii. 50 -- first part: No headers means plain text, us-ascii.
51 -- The mime.eol low-level filter normalizes end-of-line markers. 51 -- The mime.eol low-level filter normalizes end-of-line markers.
52 [1] = { 52 [1] = {
53 body = mime.eol(0, [[ 53 body = mime.eol(0, [[
54 Lines in a message body should always end with CRLF. 54 Lines in a message body should always end with CRLF.
55 The smtp module will *NOT* perform translation. It will 55 The smtp module will *NOT* perform translation. It will
56 perform necessary stuffing, though. 56 perform necessary stuffing, though.
57 ]]) 57 ]])
58 }, 58 },
59 -- second part: Headers describe content the to be an image, 59 -- second part: Headers describe content the to be an image,
60 -- sent under the base64 transfer content encoding. 60 -- sent under the base64 transfer content encoding.
61 -- Notice that nothing happens until the message is sent. Small 61 -- Notice that nothing happens until the message is sent. Small
62 -- chunks are loaded into memory and translation happens on the fly. 62 -- chunks are loaded into memory and translation happens on the fly.
63 [2] = { 63 [2] = {
64 headers = { 64 headers = {
65 ["ConTenT-tYpE"] = 'image/png; name="luasocket.png"', 65 ["ConTenT-tYpE"] = 'image/png; name="luasocket.png"',
66 ["content-disposition"] = 'attachment; filename="luasocket.png"', 66 ["content-disposition"] = 'attachment; filename="luasocket.png"',
diff --git a/test/testsupport.lua b/test/testsupport.lua
index b986088..4360b6b 100644
--- a/test/testsupport.lua
+++ b/test/testsupport.lua
@@ -7,7 +7,7 @@ function readfile(name)
7end 7end
8 8
9function similar(s1, s2) 9function similar(s1, s2)
10 return string.lower(string.gsub(s1 or "", "%s", "")) == 10 return string.lower(string.gsub(s1 or "", "%s", "")) ==
11 string.lower(string.gsub(s2 or "", "%s", "")) 11 string.lower(string.gsub(s2 or "", "%s", ""))
12end 12end
13 13
diff --git a/test/urltest.lua b/test/urltest.lua
index ae8ba75..9a3c470 100644
--- a/test/urltest.lua
+++ b/test/urltest.lua
@@ -60,8 +60,8 @@ end
60 60
61local check_absolute_url = function(base, relative, absolute) 61local check_absolute_url = function(base, relative, absolute)
62 local res = socket.url.absolute(base, relative) 62 local res = socket.url.absolute(base, relative)
63 if res ~= absolute then 63 if res ~= absolute then
64 io.write("absolute: In test for base='", base, "', rel='", relative, "' expected '", 64 io.write("absolute: In test for base='", base, "', rel='", relative, "' expected '",
65 absolute, "' but got '", res, "'\n") 65 absolute, "' but got '", res, "'\n")
66 os.exit() 66 os.exit()
67 end 67 end
@@ -73,7 +73,7 @@ local check_parse_url = function(gaba)
73 local parsed = socket.url.parse(url) 73 local parsed = socket.url.parse(url)
74 for i, v in pairs(gaba) do 74 for i, v in pairs(gaba) do
75 if v ~= parsed[i] then 75 if v ~= parsed[i] then
76 io.write("parse: In test for '", url, "' expected ", i, " = '", 76 io.write("parse: In test for '", url, "' expected ", i, " = '",
77 v, "' but got '", tostring(parsed[i]), "'\n") 77 v, "' but got '", tostring(parsed[i]), "'\n")
78 for i,v in pairs(parsed) do print(i,v) end 78 for i,v in pairs(parsed) do print(i,v) end
79 os.exit() 79 os.exit()
@@ -81,7 +81,7 @@ local check_parse_url = function(gaba)
81 end 81 end
82 for i, v in pairs(parsed) do 82 for i, v in pairs(parsed) do
83 if v ~= gaba[i] then 83 if v ~= gaba[i] then
84 io.write("parse: In test for '", url, "' expected ", i, " = '", 84 io.write("parse: In test for '", url, "' expected ", i, " = '",
85 tostring(gaba[i]), "' but got '", v, "'\n") 85 tostring(gaba[i]), "' but got '", v, "'\n")
86 for i,v in pairs(parsed) do print(i,v) end 86 for i,v in pairs(parsed) do print(i,v) end
87 os.exit() 87 os.exit()
@@ -92,8 +92,8 @@ end
92print("testing URL parsing") 92print("testing URL parsing")
93check_parse_url{ 93check_parse_url{
94 url = "scheme://user:pass$%?#wd@host:port/path;params?query#fragment", 94 url = "scheme://user:pass$%?#wd@host:port/path;params?query#fragment",
95 scheme = "scheme", 95 scheme = "scheme",
96 authority = "user:pass$%?#wd@host:port", 96 authority = "user:pass$%?#wd@host:port",
97 host = "host", 97 host = "host",
98 port = "port", 98 port = "port",
99 userinfo = "user:pass$%?#wd", 99 userinfo = "user:pass$%?#wd",
@@ -106,8 +106,8 @@ check_parse_url{
106} 106}
107check_parse_url{ 107check_parse_url{
108 url = "scheme://user:pass?#wd@host:port/path;params?query#fragment", 108 url = "scheme://user:pass?#wd@host:port/path;params?query#fragment",
109 scheme = "scheme", 109 scheme = "scheme",
110 authority = "user:pass?#wd@host:port", 110 authority = "user:pass?#wd@host:port",
111 host = "host", 111 host = "host",
112 port = "port", 112 port = "port",
113 userinfo = "user:pass?#wd", 113 userinfo = "user:pass?#wd",
@@ -120,8 +120,8 @@ check_parse_url{
120} 120}
121check_parse_url{ 121check_parse_url{
122 url = "scheme://user:pass-wd@host:port/path;params?query#fragment", 122 url = "scheme://user:pass-wd@host:port/path;params?query#fragment",
123 scheme = "scheme", 123 scheme = "scheme",
124 authority = "user:pass-wd@host:port", 124 authority = "user:pass-wd@host:port",
125 host = "host", 125 host = "host",
126 port = "port", 126 port = "port",
127 userinfo = "user:pass-wd", 127 userinfo = "user:pass-wd",
@@ -134,8 +134,8 @@ check_parse_url{
134} 134}
135check_parse_url{ 135check_parse_url{
136 url = "scheme://user:pass#wd@host:port/path;params?query#fragment", 136 url = "scheme://user:pass#wd@host:port/path;params?query#fragment",
137 scheme = "scheme", 137 scheme = "scheme",
138 authority = "user:pass#wd@host:port", 138 authority = "user:pass#wd@host:port",
139 host = "host", 139 host = "host",
140 port = "port", 140 port = "port",
141 userinfo = "user:pass#wd", 141 userinfo = "user:pass#wd",
@@ -148,8 +148,8 @@ check_parse_url{
148} 148}
149check_parse_url{ 149check_parse_url{
150 url = "scheme://user:pass#wd@host:port/path;params?query", 150 url = "scheme://user:pass#wd@host:port/path;params?query",
151 scheme = "scheme", 151 scheme = "scheme",
152 authority = "user:pass#wd@host:port", 152 authority = "user:pass#wd@host:port",
153 host = "host", 153 host = "host",
154 port = "port", 154 port = "port",
155 userinfo = "user:pass#wd", 155 userinfo = "user:pass#wd",
@@ -161,8 +161,8 @@ check_parse_url{
161} 161}
162check_parse_url{ 162check_parse_url{
163 url = "scheme://userinfo@host:port/path;params?query#fragment", 163 url = "scheme://userinfo@host:port/path;params?query#fragment",
164 scheme = "scheme", 164 scheme = "scheme",
165 authority = "userinfo@host:port", 165 authority = "userinfo@host:port",
166 host = "host", 166 host = "host",
167 port = "port", 167 port = "port",
168 userinfo = "userinfo", 168 userinfo = "userinfo",
@@ -175,8 +175,8 @@ check_parse_url{
175 175
176check_parse_url{ 176check_parse_url{
177 url = "scheme://user:password@host:port/path;params?query#fragment", 177 url = "scheme://user:password@host:port/path;params?query#fragment",
178 scheme = "scheme", 178 scheme = "scheme",
179 authority = "user:password@host:port", 179 authority = "user:password@host:port",
180 host = "host", 180 host = "host",
181 port = "port", 181 port = "port",
182 userinfo = "user:password", 182 userinfo = "user:password",
@@ -190,8 +190,8 @@ check_parse_url{
190 190
191check_parse_url{ 191check_parse_url{
192 url = "scheme://userinfo@host:port/path;params?query#", 192 url = "scheme://userinfo@host:port/path;params?query#",
193 scheme = "scheme", 193 scheme = "scheme",
194 authority = "userinfo@host:port", 194 authority = "userinfo@host:port",
195 host = "host", 195 host = "host",
196 port = "port", 196 port = "port",
197 userinfo = "userinfo", 197 userinfo = "userinfo",
@@ -204,8 +204,8 @@ check_parse_url{
204 204
205check_parse_url{ 205check_parse_url{
206 url = "scheme://userinfo@host:port/path;params?#fragment", 206 url = "scheme://userinfo@host:port/path;params?#fragment",
207 scheme = "scheme", 207 scheme = "scheme",
208 authority = "userinfo@host:port", 208 authority = "userinfo@host:port",
209 host = "host", 209 host = "host",
210 port = "port", 210 port = "port",
211 userinfo = "userinfo", 211 userinfo = "userinfo",
@@ -218,8 +218,8 @@ check_parse_url{
218 218
219check_parse_url{ 219check_parse_url{
220 url = "scheme://userinfo@host:port/path;params#fragment", 220 url = "scheme://userinfo@host:port/path;params#fragment",
221 scheme = "scheme", 221 scheme = "scheme",
222 authority = "userinfo@host:port", 222 authority = "userinfo@host:port",
223 host = "host", 223 host = "host",
224 port = "port", 224 port = "port",
225 userinfo = "userinfo", 225 userinfo = "userinfo",
@@ -231,8 +231,8 @@ check_parse_url{
231 231
232check_parse_url{ 232check_parse_url{
233 url = "scheme://userinfo@host:port/path;?query#fragment", 233 url = "scheme://userinfo@host:port/path;?query#fragment",
234 scheme = "scheme", 234 scheme = "scheme",
235 authority = "userinfo@host:port", 235 authority = "userinfo@host:port",
236 host = "host", 236 host = "host",
237 port = "port", 237 port = "port",
238 userinfo = "userinfo", 238 userinfo = "userinfo",
@@ -245,8 +245,8 @@ check_parse_url{
245 245
246check_parse_url{ 246check_parse_url{
247 url = "scheme://userinfo@host:port/path?query#fragment", 247 url = "scheme://userinfo@host:port/path?query#fragment",
248 scheme = "scheme", 248 scheme = "scheme",
249 authority = "userinfo@host:port", 249 authority = "userinfo@host:port",
250 host = "host", 250 host = "host",
251 port = "port", 251 port = "port",
252 userinfo = "userinfo", 252 userinfo = "userinfo",
@@ -258,8 +258,8 @@ check_parse_url{
258 258
259check_parse_url{ 259check_parse_url{
260 url = "scheme://userinfo@host:port/;params?query#fragment", 260 url = "scheme://userinfo@host:port/;params?query#fragment",
261 scheme = "scheme", 261 scheme = "scheme",
262 authority = "userinfo@host:port", 262 authority = "userinfo@host:port",
263 host = "host", 263 host = "host",
264 port = "port", 264 port = "port",
265 userinfo = "userinfo", 265 userinfo = "userinfo",
@@ -272,8 +272,8 @@ check_parse_url{
272 272
273check_parse_url{ 273check_parse_url{
274 url = "scheme://userinfo@host:port", 274 url = "scheme://userinfo@host:port",
275 scheme = "scheme", 275 scheme = "scheme",
276 authority = "userinfo@host:port", 276 authority = "userinfo@host:port",
277 host = "host", 277 host = "host",
278 port = "port", 278 port = "port",
279 userinfo = "userinfo", 279 userinfo = "userinfo",
@@ -282,7 +282,7 @@ check_parse_url{
282 282
283check_parse_url{ 283check_parse_url{
284 url = "//userinfo@host:port/path;params?query#fragment", 284 url = "//userinfo@host:port/path;params?query#fragment",
285 authority = "userinfo@host:port", 285 authority = "userinfo@host:port",
286 host = "host", 286 host = "host",
287 port = "port", 287 port = "port",
288 userinfo = "userinfo", 288 userinfo = "userinfo",
@@ -295,7 +295,7 @@ check_parse_url{
295 295
296check_parse_url{ 296check_parse_url{
297 url = "//userinfo@host:port/path", 297 url = "//userinfo@host:port/path",
298 authority = "userinfo@host:port", 298 authority = "userinfo@host:port",
299 host = "host", 299 host = "host",
300 port = "port", 300 port = "port",
301 userinfo = "userinfo", 301 userinfo = "userinfo",
@@ -305,7 +305,7 @@ check_parse_url{
305 305
306check_parse_url{ 306check_parse_url{
307 url = "//userinfo@host/path", 307 url = "//userinfo@host/path",
308 authority = "userinfo@host", 308 authority = "userinfo@host",
309 host = "host", 309 host = "host",
310 userinfo = "userinfo", 310 userinfo = "userinfo",
311 user = "userinfo", 311 user = "userinfo",
@@ -314,7 +314,7 @@ check_parse_url{
314 314
315check_parse_url{ 315check_parse_url{
316 url = "//user:password@host/path", 316 url = "//user:password@host/path",
317 authority = "user:password@host", 317 authority = "user:password@host",
318 host = "host", 318 host = "host",
319 userinfo = "user:password", 319 userinfo = "user:password",
320 password = "password", 320 password = "password",
@@ -324,7 +324,7 @@ check_parse_url{
324 324
325check_parse_url{ 325check_parse_url{
326 url = "//user:@host/path", 326 url = "//user:@host/path",
327 authority = "user:@host", 327 authority = "user:@host",
328 host = "host", 328 host = "host",
329 userinfo = "user:", 329 userinfo = "user:",
330 password = "", 330 password = "",
@@ -334,7 +334,7 @@ check_parse_url{
334 334
335check_parse_url{ 335check_parse_url{
336 url = "//user@host:port/path", 336 url = "//user@host:port/path",
337 authority = "user@host:port", 337 authority = "user@host:port",
338 host = "host", 338 host = "host",
339 userinfo = "user", 339 userinfo = "user",
340 user = "user", 340 user = "user",
@@ -344,7 +344,7 @@ check_parse_url{
344 344
345check_parse_url{ 345check_parse_url{
346 url = "//host:port/path", 346 url = "//host:port/path",
347 authority = "host:port", 347 authority = "host:port",
348 port = "port", 348 port = "port",
349 host = "host", 349 host = "host",
350 path = "/path", 350 path = "/path",
@@ -352,14 +352,14 @@ check_parse_url{
352 352
353check_parse_url{ 353check_parse_url{
354 url = "//host/path", 354 url = "//host/path",
355 authority = "host", 355 authority = "host",
356 host = "host", 356 host = "host",
357 path = "/path", 357 path = "/path",
358} 358}
359 359
360check_parse_url{ 360check_parse_url{
361 url = "//host", 361 url = "//host",
362 authority = "host", 362 authority = "host",
363 host = "host", 363 host = "host",
364} 364}
365 365
@@ -433,7 +433,7 @@ check_parse_url{
433 433
434check_parse_url{ 434check_parse_url{
435 url = "//userinfo@[::FFFF:129.144.52.38]:port/path;params?query#fragment", 435 url = "//userinfo@[::FFFF:129.144.52.38]:port/path;params?query#fragment",
436 authority = "userinfo@[::FFFF:129.144.52.38]:port", 436 authority = "userinfo@[::FFFF:129.144.52.38]:port",
437 host = "::FFFF:129.144.52.38", 437 host = "::FFFF:129.144.52.38",
438 port = "port", 438 port = "port",
439 userinfo = "userinfo", 439 userinfo = "userinfo",
@@ -447,7 +447,7 @@ check_parse_url{
447check_parse_url{ 447check_parse_url{
448 url = "scheme://user:password@[::192.9.5.5]:port/path;params?query#fragment", 448 url = "scheme://user:password@[::192.9.5.5]:port/path;params?query#fragment",
449 scheme = "scheme", 449 scheme = "scheme",
450 authority = "user:password@[::192.9.5.5]:port", 450 authority = "user:password@[::192.9.5.5]:port",
451 host = "::192.9.5.5", 451 host = "::192.9.5.5",
452 port = "port", 452 port = "port",
453 userinfo = "user:password", 453 userinfo = "user:password",
@@ -462,7 +462,7 @@ check_parse_url{
462print("testing URL building") 462print("testing URL building")
463check_build_url { 463check_build_url {
464 url = "scheme://user:password@host:port/path;params?query#fragment", 464 url = "scheme://user:password@host:port/path;params?query#fragment",
465 scheme = "scheme", 465 scheme = "scheme",
466 host = "host", 466 host = "host",
467 port = "port", 467 port = "port",
468 user = "user", 468 user = "user",
@@ -499,7 +499,7 @@ check_build_url{
499 499
500check_build_url { 500check_build_url {
501 url = "scheme://user:password@host/path;params?query#fragment", 501 url = "scheme://user:password@host/path;params?query#fragment",
502 scheme = "scheme", 502 scheme = "scheme",
503 host = "host", 503 host = "host",
504 user = "user", 504 user = "user",
505 password = "password", 505 password = "password",
@@ -511,7 +511,7 @@ check_build_url {
511 511
512check_build_url { 512check_build_url {
513 url = "scheme://user@host/path;params?query#fragment", 513 url = "scheme://user@host/path;params?query#fragment",
514 scheme = "scheme", 514 scheme = "scheme",
515 host = "host", 515 host = "host",
516 user = "user", 516 user = "user",
517 path = "/path", 517 path = "/path",
@@ -522,7 +522,7 @@ check_build_url {
522 522
523check_build_url { 523check_build_url {
524 url = "scheme://host/path;params?query#fragment", 524 url = "scheme://host/path;params?query#fragment",
525 scheme = "scheme", 525 scheme = "scheme",
526 host = "host", 526 host = "host",
527 path = "/path", 527 path = "/path",
528 params = "params", 528 params = "params",
@@ -532,7 +532,7 @@ check_build_url {
532 532
533check_build_url { 533check_build_url {
534 url = "scheme://host/path;params#fragment", 534 url = "scheme://host/path;params#fragment",
535 scheme = "scheme", 535 scheme = "scheme",
536 host = "host", 536 host = "host",
537 path = "/path", 537 path = "/path",
538 params = "params", 538 params = "params",
@@ -541,7 +541,7 @@ check_build_url {
541 541
542check_build_url { 542check_build_url {
543 url = "scheme://host/path#fragment", 543 url = "scheme://host/path#fragment",
544 scheme = "scheme", 544 scheme = "scheme",
545 host = "host", 545 host = "host",
546 path = "/path", 546 path = "/path",
547 fragment = "fragment" 547 fragment = "fragment"
@@ -549,7 +549,7 @@ check_build_url {
549 549
550check_build_url { 550check_build_url {
551 url = "scheme://host/path", 551 url = "scheme://host/path",
552 scheme = "scheme", 552 scheme = "scheme",
553 host = "host", 553 host = "host",
554 path = "/path", 554 path = "/path",
555} 555}
@@ -567,7 +567,7 @@ check_build_url {
567 567
568check_build_url { 568check_build_url {
569 url = "scheme://user:password@host:port/path;params?query#fragment", 569 url = "scheme://user:password@host:port/path;params?query#fragment",
570 scheme = "scheme", 570 scheme = "scheme",
571 host = "host", 571 host = "host",
572 port = "port", 572 port = "port",
573 user = "user", 573 user = "user",
@@ -581,7 +581,7 @@ check_build_url {
581 581
582check_build_url { 582check_build_url {
583 url = "scheme://user:password@host:port/path;params?query#fragment", 583 url = "scheme://user:password@host:port/path;params?query#fragment",
584 scheme = "scheme", 584 scheme = "scheme",
585 host = "host", 585 host = "host",
586 port = "port", 586 port = "port",
587 user = "user", 587 user = "user",
@@ -596,7 +596,7 @@ check_build_url {
596 596
597check_build_url { 597check_build_url {
598 url = "scheme://user:password@host:port/path;params?query#fragment", 598 url = "scheme://user:password@host:port/path;params?query#fragment",
599 scheme = "scheme", 599 scheme = "scheme",
600 host = "host", 600 host = "host",
601 port = "port", 601 port = "port",
602 userinfo = "user:password", 602 userinfo = "user:password",
@@ -609,7 +609,7 @@ check_build_url {
609 609
610check_build_url { 610check_build_url {
611 url = "scheme://user:password@host:port/path;params?query#fragment", 611 url = "scheme://user:password@host:port/path;params?query#fragment",
612 scheme = "scheme", 612 scheme = "scheme",
613 authority = "user:password@host:port", 613 authority = "user:password@host:port",
614 path = "/path", 614 path = "/path",
615 params = "params", 615 params = "params",
@@ -683,7 +683,7 @@ check_absolute_url("//a/b/c/d;p?q#f", "d/e/f", "//a/b/c/d/e/f")
683check_absolute_url("/a/b/c/d;p?q#f", "d/e/f", "/a/b/c/d/e/f") 683check_absolute_url("/a/b/c/d;p?q#f", "d/e/f", "/a/b/c/d/e/f")
684check_absolute_url("a/b/c/d", "d/e/f", "a/b/c/d/e/f") 684check_absolute_url("a/b/c/d", "d/e/f", "a/b/c/d/e/f")
685check_absolute_url("a/b/c/d/../", "d/e/f", "a/b/c/d/e/f") 685check_absolute_url("a/b/c/d/../", "d/e/f", "a/b/c/d/e/f")
686check_absolute_url("http://velox.telemar.com.br", "/dashboard/index.html", 686check_absolute_url("http://velox.telemar.com.br", "/dashboard/index.html",
687 "http://velox.telemar.com.br/dashboard/index.html") 687 "http://velox.telemar.com.br/dashboard/index.html")
688check_absolute_url("http://example.com/", "../.badhost.com/", "http://example.com/.badhost.com/") 688check_absolute_url("http://example.com/", "../.badhost.com/", "http://example.com/.badhost.com/")
689check_absolute_url("http://example.com/", "...badhost.com/", "http://example.com/...badhost.com/") 689check_absolute_url("http://example.com/", "...badhost.com/", "http://example.com/...badhost.com/")
@@ -700,11 +700,11 @@ check_absolute_url("http://example.com/a/b/c/d/", "../x/a/../y/z/../../../../q",
700print("testing path parsing and composition") 700print("testing path parsing and composition")
701check_parse_path("/eu/tu/ele", { "eu", "tu", "ele"; is_absolute = 1 }) 701check_parse_path("/eu/tu/ele", { "eu", "tu", "ele"; is_absolute = 1 })
702check_parse_path("/eu/", { "eu"; is_absolute = 1, is_directory = 1 }) 702check_parse_path("/eu/", { "eu"; is_absolute = 1, is_directory = 1 })
703check_parse_path("eu/tu/ele/nos/vos/eles/", 703check_parse_path("eu/tu/ele/nos/vos/eles/",
704 { "eu", "tu", "ele", "nos", "vos", "eles"; is_directory = 1}) 704 { "eu", "tu", "ele", "nos", "vos", "eles"; is_directory = 1})
705check_parse_path("/", { is_absolute = 1, is_directory = 1}) 705check_parse_path("/", { is_absolute = 1, is_directory = 1})
706check_parse_path("", { }) 706check_parse_path("", { })
707check_parse_path("eu%01/%02tu/e%03l%04e/nos/vos%05/e%12les/", 707check_parse_path("eu%01/%02tu/e%03l%04e/nos/vos%05/e%12les/",
708 { "eu\1", "\2tu", "e\3l\4e", "nos", "vos\5", "e\18les"; is_directory = 1}) 708 { "eu\1", "\2tu", "e\3l\4e", "nos", "vos\5", "e\18les"; is_directory = 1})
709check_parse_path("eu/tu", { "eu", "tu" }) 709check_parse_path("eu/tu", { "eu", "tu" })
710 710
diff --git a/test/utestclnt.lua b/test/utestclnt.lua
index 34a0718..7f10643 100644
--- a/test/utestclnt.lua
+++ b/test/utestclnt.lua
@@ -54,30 +54,30 @@ function check_timeout(tm, sl, elapsed, err, opp, mode, alldone)
54 if not err then warn("must be buffered") 54 if not err then warn("must be buffered")
55 elseif err == "timeout" then pass("proper timeout") 55 elseif err == "timeout" then pass("proper timeout")
56 else fail("unexpected error '%s'", err) end 56 else fail("unexpected error '%s'", err) end
57 else 57 else
58 if err ~= "timeout" then fail("should have timed out") 58 if err ~= "timeout" then fail("should have timed out")
59 else pass("proper timeout") end 59 else pass("proper timeout") end
60 end 60 end
61 else 61 else
62 if mode == "total" then 62 if mode == "total" then
63 if elapsed > tm then 63 if elapsed > tm then
64 if err ~= "timeout" then fail("should have timed out") 64 if err ~= "timeout" then fail("should have timed out")
65 else pass("proper timeout") end 65 else pass("proper timeout") end
66 elseif elapsed < tm then 66 elseif elapsed < tm then
67 if err then fail(err) 67 if err then fail(err)
68 else pass("ok") end 68 else pass("ok") end
69 else 69 else
70 if alldone then 70 if alldone then
71 if err then fail("unexpected error '%s'", err) 71 if err then fail("unexpected error '%s'", err)
72 else pass("ok") end 72 else pass("ok") end
73 else 73 else
74 if err ~= "timeout" then fail(err) 74 if err ~= "timeout" then fail(err)
75 else pass("proper timeoutk") end 75 else pass("proper timeoutk") end
76 end 76 end
77 end 77 end
78 else 78 else
79 if err then fail(err) 79 if err then fail(err)
80 else pass("ok") end 80 else pass("ok") end
81 end 81 end
82 end 82 end
83end 83end
@@ -104,7 +104,7 @@ function reconnect()
104 print("done " .. i) 104 print("done " .. i)
105 ]] 105 ]]
106 data, err = uconnect(host, port) 106 data, err = uconnect(host, port)
107 if not data then fail(err) 107 if not data then fail(err)
108 else pass("connected!") end 108 else pass("connected!") end
109end 109end
110 110
@@ -116,8 +116,8 @@ else pass("connected!") end
116------------------------------------------------------------------------ 116------------------------------------------------------------------------
117function test_methods(sock, methods) 117function test_methods(sock, methods)
118 for _, v in pairs(methods) do 118 for _, v in pairs(methods) do
119 if type(sock[v]) ~= "function" then 119 if type(sock[v]) ~= "function" then
120 fail(sock.class .. " method '" .. v .. "' not registered") 120 fail(sock.class .. " method '" .. v .. "' not registered")
121 end 121 end
122 end 122 end
123 pass(sock.class .. " methods are ok") 123 pass(sock.class .. " methods are ok")
@@ -132,7 +132,7 @@ function test_mixed(len)
132 local p3 = "raw " .. string.rep("z", inter) .. "bytes" 132 local p3 = "raw " .. string.rep("z", inter) .. "bytes"
133 local p4 = "end" .. string.rep("w", inter) .. "bytes" 133 local p4 = "end" .. string.rep("w", inter) .. "bytes"
134 local bp1, bp2, bp3, bp4 134 local bp1, bp2, bp3, bp4
135remote (string.format("str = data:receive(%d)", 135remote (string.format("str = data:receive(%d)",
136 string.len(p1)+string.len(p2)+string.len(p3)+string.len(p4))) 136 string.len(p1)+string.len(p2)+string.len(p3)+string.len(p4)))
137 sent, err = data:send(p1..p2..p3..p4) 137 sent, err = data:send(p1..p2..p3..p4)
138 if err then fail(err) end 138 if err then fail(err) end
@@ -172,7 +172,7 @@ function test_rawline(len)
172 reconnect() 172 reconnect()
173 local str, str10, back, err 173 local str, str10, back, err
174 str = string.rep(string.char(47), math.mod(len, 10)) 174 str = string.rep(string.char(47), math.mod(len, 10))
175 str10 = string.rep(string.char(120,21,77,4,5,0,7,36,44,100), 175 str10 = string.rep(string.char(120,21,77,4,5,0,7,36,44,100),
176 math.floor(len/10)) 176 math.floor(len/10))
177 str = str .. str10 177 str = str .. str10
178remote "str = data:receive()" 178remote "str = data:receive()"
@@ -221,7 +221,7 @@ function test_totaltimeoutreceive(len, tm, sl)
221 data:settimeout(tm, "total") 221 data:settimeout(tm, "total")
222local t = socket.gettime() 222local t = socket.gettime()
223 str, err, partial, elapsed = data:receive(2*len) 223 str, err, partial, elapsed = data:receive(2*len)
224 check_timeout(tm, sl, elapsed, err, "receive", "total", 224 check_timeout(tm, sl, elapsed, err, "receive", "total",
225 string.len(str or partial) == 2*len) 225 string.len(str or partial) == 2*len)
226end 226end
227 227
@@ -241,7 +241,7 @@ function test_totaltimeoutsend(len, tm, sl)
241 data:settimeout(tm, "total") 241 data:settimeout(tm, "total")
242 str = string.rep("a", 2*len) 242 str = string.rep("a", 2*len)
243 total, err, partial, elapsed = data:send(str) 243 total, err, partial, elapsed = data:send(str)
244 check_timeout(tm, sl, elapsed, err, "send", "total", 244 check_timeout(tm, sl, elapsed, err, "send", "total",
245 total == 2*len) 245 total == 2*len)
246end 246end
247 247
@@ -261,7 +261,7 @@ function test_blockingtimeoutreceive(len, tm, sl)
261 ]], 2*tm, len, sl, sl)) 261 ]], 2*tm, len, sl, sl))
262 data:settimeout(tm) 262 data:settimeout(tm)
263 str, err, partial, elapsed = data:receive(2*len) 263 str, err, partial, elapsed = data:receive(2*len)
264 check_timeout(tm, sl, elapsed, err, "receive", "blocking", 264 check_timeout(tm, sl, elapsed, err, "receive", "blocking",
265 string.len(str or partial) == 2*len) 265 string.len(str or partial) == 2*len)
266end 266end
267 267
@@ -294,10 +294,10 @@ function empty_connect()
294 data = server:accept() 294 data = server:accept()
295 ]] 295 ]]
296 data, err = socket.connect("", port) 296 data, err = socket.connect("", port)
297 if not data then 297 if not data then
298 pass("ok") 298 pass("ok")
299 data = socket.connect(host, port) 299 data = socket.connect(host, port)
300 else 300 else
301 pass("gethostbyname returns localhost on empty string...") 301 pass("gethostbyname returns localhost on empty string...")
302 end 302 end
303end 303end
@@ -331,7 +331,7 @@ function test_closed()
331 data:close() 331 data:close()
332 data = nil 332 data = nil
333 ]], str)) 333 ]], str))
334 -- try to get a line 334 -- try to get a line
335 back, err, partial = data:receive() 335 back, err, partial = data:receive()
336 if not err then fail("should have gotten 'closed'.") 336 if not err then fail("should have gotten 'closed'.")
337 elseif err ~= "closed" then fail("got '"..err.."' instead of 'closed'.") 337 elseif err ~= "closed" then fail("got '"..err.."' instead of 'closed'.")
@@ -344,25 +344,25 @@ function test_closed()
344 data = nil 344 data = nil
345 ]] 345 ]]
346 total, err, partial = data:send(string.rep("ugauga", 100000)) 346 total, err, partial = data:send(string.rep("ugauga", 100000))
347 if not err then 347 if not err then
348 pass("failed: output buffer is at least %d bytes long!", total) 348 pass("failed: output buffer is at least %d bytes long!", total)
349 elseif err ~= "closed" then 349 elseif err ~= "closed" then
350 fail("got '"..err.."' instead of 'closed'.") 350 fail("got '"..err.."' instead of 'closed'.")
351 else 351 else
352 pass("graceful 'closed' received after %d bytes were sent", partial) 352 pass("graceful 'closed' received after %d bytes were sent", partial)
353 end 353 end
354end 354end
355 355
356------------------------------------------------------------------------ 356------------------------------------------------------------------------
357function test_selectbugs() 357function test_selectbugs()
358 local r, s, e = socket.select(nil, nil, 0.1) 358 local r, s, e = socket.select(nil, nil, 0.1)
359 assert(type(r) == "table" and type(s) == "table" and 359 assert(type(r) == "table" and type(s) == "table" and
360 (e == "timeout" or e == "error")) 360 (e == "timeout" or e == "error"))
361 pass("both nil: ok") 361 pass("both nil: ok")
362 local udp = socket.udp() 362 local udp = socket.udp()
363 udp:close() 363 udp:close()
364 r, s, e = socket.select({ udp }, { udp }, 0.1) 364 r, s, e = socket.select({ udp }, { udp }, 0.1)
365 assert(type(r) == "table" and type(s) == "table" and 365 assert(type(r) == "table" and type(s) == "table" and
366 (e == "timeout" or e == "error")) 366 (e == "timeout" or e == "error"))
367 pass("closed sockets: ok") 367 pass("closed sockets: ok")
368 e = pcall(socket.select, "wrong", 1, 0.1) 368 e = pcall(socket.select, "wrong", 1, 0.1)
@@ -380,7 +380,7 @@ function accept_timeout()
380 local t = socket.gettime() 380 local t = socket.gettime()
381 s:settimeout(1) 381 s:settimeout(1)
382 local c, e = s:accept() 382 local c, e = s:accept()
383 assert(not c, "should not accept") 383 assert(not c, "should not accept")
384 assert(e == "timeout", string.format("wrong error message (%s)", e)) 384 assert(e == "timeout", string.format("wrong error message (%s)", e))
385 t = socket.gettime() - t 385 t = socket.gettime() - t
386 assert(t < 2, string.format("took to long to give up (%gs)", t)) 386 assert(t < 2, string.format("took to long to give up (%gs)", t))
@@ -398,9 +398,9 @@ function connect_timeout()
398 local t = socket.gettime() 398 local t = socket.gettime()
399 local r, e = c:connect("127.0.0.2", 80) 399 local r, e = c:connect("127.0.0.2", 80)
400 assert(not r, "should not connect") 400 assert(not r, "should not connect")
401 assert(socket.gettime() - t < 2, "took too long to give up.") 401 assert(socket.gettime() - t < 2, "took too long to give up.")
402 c:close() 402 c:close()
403 print("ok") 403 print("ok")
404end 404end
405 405
406------------------------------------------------------------------------ 406------------------------------------------------------------------------
@@ -463,9 +463,9 @@ function getstats_test()
463 data:receive(c) 463 data:receive(c)
464 t = t + c 464 t = t + c
465 local r, s, a = data:getstats() 465 local r, s, a = data:getstats()
466 assert(r == t, "received count failed" .. tostring(r) 466 assert(r == t, "received count failed" .. tostring(r)
467 .. "/" .. tostring(t)) 467 .. "/" .. tostring(t))
468 assert(s == t, "sent count failed" .. tostring(s) 468 assert(s == t, "sent count failed" .. tostring(s)
469 .. "/" .. tostring(t)) 469 .. "/" .. tostring(t))
470 end 470 end
471 print("ok") 471 print("ok")
@@ -473,7 +473,7 @@ end
473 473
474 474
475------------------------------------------------------------------------ 475------------------------------------------------------------------------
476function test_nonblocking(size) 476function test_nonblocking(size)
477 reconnect() 477 reconnect()
478print("Testing " .. 2*size .. " bytes") 478print("Testing " .. 2*size .. " bytes")
479remote(string.format([[ 479remote(string.format([[
diff --git a/test/utestsrvr.lua b/test/utestsrvr.lua
index a96b570..b6e4246 100644
--- a/test/utestsrvr.lua
+++ b/test/utestsrvr.lua
@@ -9,7 +9,7 @@ ack = "\n";
9while 1 do 9while 1 do
10 print("server: waiting for client connection..."); 10 print("server: waiting for client connection...");
11 control = assert(server:accept()); 11 control = assert(server:accept());
12 while 1 do 12 while 1 do
13 command = assert(control:receive()); 13 command = assert(control:receive());
14 assert(control:send(ack)); 14 assert(control:send(ack));
15 ((loadstring or load)(command))(); 15 ((loadstring or load)(command))();