28 function urlencode(s) return s and (s:gsub("%W", function (c) return format("%%%02x", c:byte()); end)); end |
28 function urlencode(s) return s and (s:gsub("%W", function (c) return format("%%%02x", c:byte()); end)); end |
29 function urldecode(s) return s and (s:gsub("%%(%x%x)", function (c) return char(tonumber(c,16)); end)); end |
29 function urldecode(s) return s and (s:gsub("%%(%x%x)", function (c) return char(tonumber(c,16)); end)); end |
30 |
30 |
31 local function expectbody(reqt, code) |
31 local function expectbody(reqt, code) |
32 if reqt.method == "HEAD" then return nil end |
32 if reqt.method == "HEAD" then return nil end |
33 if code == 204 or code == 304 then return nil end |
33 if code == 204 or code == 304 or code == 301 then return nil end |
34 if code >= 100 and code < 200 then return nil end |
34 if code >= 100 and code < 200 then return nil end |
35 return 1 |
35 return 1 |
36 end |
36 end |
37 |
37 |
38 local function request_reader(request, data, startpos) |
38 local function request_reader(request, data, startpos) |