aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2011-08-20 16:51:47 -0400
committerMatthew Wild <mwild1@gmail.com>2011-08-20 16:51:47 -0400
commite3d1510338e26d7b138c4f287cda91f5717d17d9 (patch)
tree2734cd775e696bd4ec8e0239901a92cdac7be5e5
parenta40ad30126e2ee8696561afb0353dec132057d44 (diff)
downloadprosody-e3d1510338e26d7b138c4f287cda91f5717d17d9.tar.gz
prosody-e3d1510338e26d7b138c4f287cda91f5717d17d9.zip
net.http: Support for k->v maps in http.formencode
-rw-r--r--net/http.lua10
1 files changed, 8 insertions, 2 deletions
diff --git a/net/http.lua b/net/http.lua
index df4d9a02..1fdde22c 100644
--- a/net/http.lua
+++ b/net/http.lua
@@ -40,8 +40,14 @@ end
function formencode(form)
local result = {};
- for _, field in ipairs(form) do
- t_insert(result, _formencodepart(field.name).."=".._formencodepart(field.value));
+ if form[1] then -- Array of ordered { name, value }
+ for _, field in ipairs(form) do
+ t_insert(result, _formencodepart(field.name).."=".._formencodepart(field.value));
+ end
+ else -- Unordered map of name -> value
+ for name, value in pairs(form) do
+ t_insert(result, _formencodepart(name).."=".._formencodepart(value));
+ end
end
return t_concat(result, "&");
end