format_http_params function

This commit is contained in:
yago 2015-03-14 17:22:52 +01:00
parent 29ca79a193
commit c58e507032

View File

@ -365,3 +365,22 @@ function send_document_from_url(receiver, url, cb_function, cb_extra)
print("File path: "..file_path) print("File path: "..file_path)
_send_document(receiver, file_path, cb_function, cb_extra) _send_document(receiver, file_path, cb_function, cb_extra)
end end
-- Parameters in ?a=1&b=2 style
function format_http_params(params, is_get)
local str = ''
-- If is get add ? to the beginning
if is_get then str = '?' end
local first = true -- Frist param
for k,v in pairs (params) do
if v then -- nil value
if first then
first = false
str = str..k.. "="..v
else
str = str.."&"..k.. "="..v
end
end
end
return str
end