Software /
code /
prosody
Comparison
net/http.lua @ 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 |
parent | 4352:912a49b1c4e3 |
child | 4356:10a4f3b081a7 |
comparison
equal
deleted
inserted
replaced
4354:502876d94363 | 4355:9e2a841739b5 |
---|---|
38 end)); | 38 end)); |
39 end | 39 end |
40 | 40 |
41 function formencode(form) | 41 function formencode(form) |
42 local result = {}; | 42 local result = {}; |
43 for _, field in ipairs(form) do | 43 if form[1] then -- Array of ordered { name, value } |
44 t_insert(result, _formencodepart(field.name).."=".._formencodepart(field.value)); | 44 for _, field in ipairs(form) do |
45 t_insert(result, _formencodepart(field.name).."=".._formencodepart(field.value)); | |
46 end | |
47 else -- Unordered map of name -> value | |
48 for name, value in pairs(form) do | |
49 t_insert(result, _formencodepart(name).."=".._formencodepart(value)); | |
50 end | |
45 end | 51 end |
46 return t_concat(result, "&"); | 52 return t_concat(result, "&"); |
47 end | 53 end |
48 | 54 |
49 function formdecode(s) | 55 function formdecode(s) |