aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2009-06-12 11:21:25 +0100
committerMatthew Wild <mwild1@gmail.com>2009-06-12 11:21:25 +0100
commit6a38f3d21939c1dacdbb8b4050a4a046e25b9451 (patch)
tree20631d6ce8c2e70d6aa5f69038bfa6054edd8559
parentd0d6966f9d8f0f3dbb6a04de3bcf6d8ab41f593f (diff)
parent12d17990b6ab12e8244f1f01ddad7f4528023b61 (diff)
downloadprosody-6a38f3d21939c1dacdbb8b4050a4a046e25b9451.tar.gz
prosody-6a38f3d21939c1dacdbb8b4050a4a046e25b9451.zip
Automated merge with http://waqas.ath.cx:8000/
-rw-r--r--net/http.lua9
1 files changed, 5 insertions, 4 deletions
diff --git a/net/http.lua b/net/http.lua
index b39cc6fb..10d96631 100644
--- a/net/http.lua
+++ b/net/http.lua
@@ -9,16 +9,17 @@ local connlisteners_get = require "net.connlisteners".get;
local listener = connlisteners_get("httpclient") or error("No httpclient listener!");
local t_insert, t_concat = table.insert, table.concat;
-local tonumber, tostring, pairs, xpcall, select, debug_traceback, char =
- tonumber, tostring, pairs, xpcall, select, debug.traceback, string.char;
+local tonumber, tostring, pairs, xpcall, select, debug_traceback, char, format =
+ tonumber, tostring, pairs, xpcall, select, debug.traceback, string.char, string.format;
local log = require "util.logger".init("http");
local print = function () end
-local urlencode = function (s) return s and (s:gsub("%W", function (c) return string.format("%%%02x", c:byte()); end)); end
-
module "http"
+function urlencode(s) return s and (s:gsub("%W", function (c) return format("%%%02x", c:byte()); end)); end
+function urldecode(s) return s and (s:gsub("%%(%x%x)", function (c) return char(tonumber(c,16)); end)); end
+
local function expectbody(reqt, code)
if reqt.method == "HEAD" then return nil end
if code == 204 or code == 304 then return nil end