# HG changeset patch # User Matthew Wild # Date 1326760252 0 # Node ID ea24d73e6c940f84b78e43567c080b29870b80a2 # Parent 0209bd5c4259e1cec62a81105992a9a7bc54a0cb net.http: Pass response object to callbacks (feels hacky, should this be passed *instead of* the request?) diff -r 0209bd5c4259 -r ea24d73e6c94 net/http.lua --- 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";