Automated merge with http://waqas.ath.cx:8000/

Fri, 12 Jun 2009 11:21:25 +0100

author
Matthew Wild <mwild1@gmail.com>
date
Fri, 12 Jun 2009 11:21:25 +0100
changeset 1336
389b4fb48901
parent 1335
7c71783b40cf (current diff)
parent 1331
4443309b5528 (diff)
child 1337
16c5aa4696ca
child 1338
0bfc8d866479

Automated merge with http://waqas.ath.cx:8000/

--- 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

mercurial