net.http: Update print()s to log()s - don't ask how this came to be, I have no idea :)

Fri, 19 Feb 2010 03:27:18 +0000

author
Matthew Wild <mwild1@gmail.com>
date
Fri, 19 Feb 2010 03:27:18 +0000
changeset 2675
ab643a77da2d
parent 2674
a1fdfd7318df
child 2676
4516888fc42d

net.http: Update print()s to log()s - don't ask how this came to be, I have no idea :)

net/http.lua file | annotate | diff | comparison | revisions
--- a/net/http.lua	Fri Feb 19 03:23:51 2010 +0000
+++ b/net/http.lua	Fri Feb 19 03:27:18 2010 +0000
@@ -17,11 +17,10 @@
 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, format = 
+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
 
 module "http"
 
@@ -51,7 +50,7 @@
 		return;
 	end
 	if request.state == "body" and request.state ~= "completed" then
-		print("Reading body...")
+		log("debug", "Reading body...")
 		if not request.body then request.body = {}; request.havebodylength, request.bodylength = 0, tonumber(request.responseheaders["content-length"]); end
 		if startpos then
 			data = data:sub(startpos, -1)
@@ -68,11 +67,11 @@
 				request.body = nil;
 				request.state = "completed";
 			else
-				print("", "Have "..request.havebodylength.." bytes out of "..request.bodylength);
+				log("debug", "Have "..request.havebodylength.." bytes out of "..request.bodylength);
 			end
 		end
 	elseif request.state == "headers" then
-		print("Reading headers...")
+		log("debug", "Reading headers...")
 		local pos = startpos;
 		local headers, headers_complete = request.responseheaders;
 		if not headers then
@@ -84,12 +83,12 @@
 			local k, v = line:match("(%S+): (.+)");
 			if k and v then
 				headers[k:lower()] = v;
-				--print("Header: "..k:lower().." = "..v);
+				--log("debug", "Header: "..k:lower().." = "..v);
 			elseif #line == 0 then
 				headers_complete = true;
 				break;
 			else
-				print("Unhandled header line: "..line);
+				log("warn", "Unhandled header line: "..line);
 			end
 		end
 		if not headers_complete then return; end
@@ -103,7 +102,7 @@
 			return request_reader(request, data, startpos);
 		end
 	elseif request.state == "status" then
-		print("Reading status...")
+		log("debug", "Reading status...")
 		local http, code, text, linelen = data:match("^HTTP/(%S+) (%d+) (.-)\r\n()", startpos);
 		code = tonumber(code);
 		if not code then

mercurial