Software /
code /
prosody
Changeset
1336:389b4fb48901
Automated merge with http://waqas.ath.cx:8000/
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Fri, 12 Jun 2009 11:21:25 +0100 |
parents | 1335:7c71783b40cf (current diff) 1331:4443309b5528 (diff) |
children | 1337:16c5aa4696ca 1338:0bfc8d866479 |
files | |
diffstat | 1 files changed, 5 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/net/http.lua Fri Jun 12 14:35:52 2009 +0500 +++ b/net/http.lua Fri Jun 12 11:21:25 2009 +0100 @@ -9,15 +9,16 @@ local listener = connlisteners_get("httpclient") or error("No httpclient listener!"); local t_insert, t_concat = table.insert, table.concat; -local tonumber, tostring, pairs, xpcall, select, debug_traceback, char = - tonumber, tostring, pairs, xpcall, select, debug.traceback, string.char; +local tonumber, tostring, pairs, xpcall, select, debug_traceback, char, format = + tonumber, tostring, pairs, xpcall, select, debug.traceback, string.char, string.format; local log = require "util.logger".init("http"); local print = function () end -local urlencode = function (s) return s and (s:gsub("%W", function (c) return string.format("%%%02x", c:byte()); end)); end +module "http" -module "http" +function urlencode(s) return s and (s:gsub("%W", function (c) return format("%%%02x", c:byte()); end)); end +function urldecode(s) return s and (s:gsub("%%(%x%x)", function (c) return char(tonumber(c,16)); end)); end local function expectbody(reqt, code) if reqt.method == "HEAD" then return nil end