Diff

net/http.lua @ 4471:ea24d73e6c94

net.http: Pass response object to callbacks (feels hacky, should this be passed *instead of* the request?)
author Matthew Wild <mwild1@gmail.com>
date Tue, 17 Jan 2012 00:30:52 +0000
parent 4369:3578ff5d3674
child 4557:2abe4e541d52
line wrap: on
line diff
--- a/net/http.lua	Fri Jan 13 23:30:32 2012 +0000
+++ b/net/http.lua	Tue Jan 17 00:30:52 2012 +0000
@@ -70,7 +70,7 @@
 		local function success_cb(r)
 			if request.callback then
 				for k,v in pairs(r) do request[k] = v; end
-				request.callback(r.body, r.code, request);
+				request.callback(r.body, r.code, request, r);
 				request.callback = nil;
 			end
 			destroy_request(request);
@@ -148,7 +148,7 @@
 	req.handler, req.conn = server.wrapclient(conn, req.host, port, listener, "*a", using_https and { mode = "client", protocol = "sslv23" });
 	req.write = function (...) return req.handler:write(...); end
 	
-	req.callback = function (content, code, request) log("debug", "Calling callback, status %s", code or "---"); return select(2, xpcall(function () return callback(content, code, request) end, handleerr)); end
+	req.callback = function (content, code, request, response) log("debug", "Calling callback, status %s", code or "---"); return select(2, xpcall(function () return callback(content, code, request, response) end, handleerr)); end
 	req.reader = request_reader;
 	req.state = "status";