# HG changeset patch # User Matthew Wild # Date 1244802085 -3600 # Node ID 389b4fb489014a38e2058e323c83cdafbacb5007 # Parent 7c71783b40cf1144e1b97ae8808a6846be43e913# Parent 4443309b55283db4dcd4833acffa44dd27299ce2 Automated merge with http://waqas.ath.cx:8000/ diff -r 7c71783b40cf -r 389b4fb48901 net/http.lua --- 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