Software /
code /
prosody
Changeset
4355:9e2a841739b5
net.http: Support for k->v maps in http.formencode
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sat, 20 Aug 2011 16:51:47 -0400 |
parents | 4354:502876d94363 |
children | 4356:10a4f3b081a7 |
files | net/http.lua |
diffstat | 1 files changed, 8 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/net/http.lua Sat Aug 20 16:51:17 2011 -0400 +++ b/net/http.lua Sat Aug 20 16:51:47 2011 -0400 @@ -40,8 +40,14 @@ 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