aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--net/http.lua13
1 files changed, 13 insertions, 0 deletions
diff --git a/net/http.lua b/net/http.lua
index 6c8e0a68..5b9831ac 100644
--- a/net/http.lua
+++ b/net/http.lua
@@ -38,6 +38,7 @@ local function _formencodepart(s)
end
end));
end
+
function formencode(form)
local result = {};
for _, field in ipairs(form) do
@@ -46,6 +47,18 @@ function formencode(form)
return t_concat(result, "&");
end
+function formdecode(s)
+ if not s:match("=") then return urldecode(s); end
+ local r = {};
+ for k, v in s:gmatch("([^=&]*)=([^&]*)") do
+ k, v = k:gsub("%+", "%%20"), v:gsub("%+", "%%20");
+ k, v = urldecode(k), urldecode(v);
+ t_insert(r, { name = k, value = v });
+ r[k] = v;
+ end
+ return r;
+end
+
local function request_reader(request, data, startpos)
if not request.parser then
local function success_cb(r)