11 local t_insert, t_concat = table.insert, table.concat; |
11 local t_insert, t_concat = table.insert, table.concat; |
12 local tonumber, tostring, pairs = tonumber, tostring, pairs; |
12 local tonumber, tostring, pairs = tonumber, tostring, pairs; |
13 local print = function () end |
13 local print = function () end |
14 |
14 |
15 local urlcodes = setmetatable({}, { __index = function (t, k) t[k] = char(tonumber("0x"..k)); return t[k]; end }); |
15 local urlcodes = setmetatable({}, { __index = function (t, k) t[k] = char(tonumber("0x"..k)); return t[k]; end }); |
16 local urlencode = function (s) return s and (s:gsub("%W", function (c) return string.format("%%%x", c:byte()); end)); end |
16 local urlencode = function (s) return s and (s:gsub("%W", function (c) return string.format("%%%02x", c:byte()); end)); end |
17 |
17 |
18 module "http" |
18 module "http" |
19 |
19 |
20 local function expectbody(reqt, code) |
20 local function expectbody(reqt, code) |
21 if reqt.method == "HEAD" then return nil end |
21 if reqt.method == "HEAD" then return nil end |