* libs/web: Fixed Luci template cache
[project/luci.git] / libs / web / luasrc / http.lua
index fa8821c..3bff28a 100644 (file)
@@ -33,4 +33,30 @@ if ENV and ENV.HASERLVER then
        require("luci.sgi.haserl")
 elseif webuci then
        require("luci.sgi.webuci")
+end
+
+function build_querystring(table)
+       local s="?"
+       
+       for k, v in pairs(table) do
+               s = s .. k .. "=" .. v .. "&"
+       end
+       
+       return s
+end
+
+function urldecode(str)
+       str = str:gsub("+", " ")
+       str = str:gsub("%%(%x%x)",
+               function(h) return string.char(tonumber(h,16)) end)
+       str = str:gsub("\r\n", "\n")
+       return str      
+end
+
+function urlencode(str)
+       str = str:gsub("\n", "\r\n")
+       str = str:gsub("([^%w ])",
+               function (c) return string.format ("%%%02X", string.byte(c)) end)
+       str = str:gsub(" ", "+")
+       return str      
 end
\ No newline at end of file