aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2013-04-15 16:43:08 +0100
committerMatthew Wild <mwild1@gmail.com>2013-04-15 16:43:08 +0100
commit7d8f9c74e732470bfef35f862e2434b7fd8cc746 (patch)
tree283cdf9c8f06279d6e30071dcf82fcb1dfd09a44
parenta9a591ecb9cdfa3e37f2076b2f3c3f23cf320233 (diff)
parent47fe2a07750bfd747487613067354659e868f9b6 (diff)
downloadprosody-7d8f9c74e732470bfef35f862e2434b7fd8cc746.tar.gz
prosody-7d8f9c74e732470bfef35f862e2434b7fd8cc746.zip
Merge 0.9->trunk
-rw-r--r--Makefile2
-rw-r--r--util/http.lua22
2 files changed, 14 insertions, 10 deletions
diff --git a/Makefile b/Makefile
index 0e69192a..b96b6732 100644
--- a/Makefile
+++ b/Makefile
@@ -38,7 +38,7 @@ install: prosody.install prosodyctl.install prosody.cfg.lua.install util/encodin
install -m644 certs/* $(CONFIG)/certs
install -m644 man/prosodyctl.man $(MAN)/man1/prosodyctl.1
test -e $(CONFIG)/prosody.cfg.lua || install -m644 prosody.cfg.lua.install $(CONFIG)/prosody.cfg.lua
- test -e prosody.version && install prosody.version $(SOURCE)/prosody.version || true
+ test -e prosody.version && install -m644 prosody.version $(SOURCE)/prosody.version || true
$(MAKE) install -C util-src
clean:
diff --git a/util/http.lua b/util/http.lua
index 5dd636d9..f7259920 100644
--- a/util/http.lua
+++ b/util/http.lua
@@ -5,12 +5,14 @@
-- COPYING file in the source package for more information.
--
-local http = {};
+local format, char = string.format, string.char;
+local pairs, ipairs, tonumber = pairs, ipairs, tonumber;
+local t_insert, t_concat = table.insert, table.concat;
-function http.urlencode(s)
+local function urlencode(s)
return s and (s:gsub("[^a-zA-Z0-9.~_-]", function (c) return format("%%%02x", c:byte()); end));
end
-function http.urldecode(s)
+local function urldecode(s)
return s and (s:gsub("%%(%x%x)", function (c) return char(tonumber(c,16)); end));
end
@@ -24,7 +26,7 @@ local function _formencodepart(s)
end));
end
-function http.formencode(form)
+local function formencode(form)
local result = {};
if form[1] then -- Array of ordered { name, value }
for _, field in ipairs(form) do
@@ -38,7 +40,7 @@ function http.formencode(form)
return t_concat(result, "&");
end
-function http.formdecode(s)
+local function formdecode(s)
if not s:match("=") then return urldecode(s); end
local r = {};
for k, v in s:gmatch("([^=&]*)=([^&]*)") do
@@ -50,11 +52,13 @@ function http.formdecode(s)
return r;
end
-function http.contains_token(field, token)
+local function contains_token(field, token)
field = ","..field:gsub("[ \t]", ""):lower()..",";
return field:find(","..token:lower()..",", 1, true) ~= nil;
end
-
-
-return http;
+return {
+ urlencode = urlencode, urldecode = urldecode;
+ formencode = formencode, formdecode = formdecode;
+ contains_token = contains_token;
+};