Software /
code /
prosody
Comparison
net/http.lua @ 628:3712d36b6d25
Fixed URL encoding to generate %0x instead of %x
author | Waqas Hussain <waqas20@gmail.com> |
---|---|
date | Tue, 16 Dec 2008 03:46:17 +0500 |
parent | 619:6d720aba51cb |
child | 633:fe1e01a06729 |
comparison
equal
deleted
inserted
replaced
621:cd2cab5400fc | 628:3712d36b6d25 |
---|---|
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 |