aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2008-12-12 04:30:35 +0000
committerMatthew Wild <mwild1@gmail.com>2008-12-12 04:30:35 +0000
commitd18299fec9e995407ae71e4a06bd0de7e3772872 (patch)
tree358a9f772f4cf212cbd9c3caf90abacfd3ab0cdc /net
parent4b6cff1b8dae6b4b40faebe61be3074862bec189 (diff)
downloadprosody-d18299fec9e995407ae71e4a06bd0de7e3772872.tar.gz
prosody-d18299fec9e995407ae71e4a06bd0de7e3772872.zip
Pass HTTP request object to callback
Diffstat (limited to 'net')
-rw-r--r--net/http.lua10
1 files changed, 5 insertions, 5 deletions
diff --git a/net/http.lua b/net/http.lua
index 9a2249f2..628290e8 100644
--- a/net/http.lua
+++ b/net/http.lua
@@ -27,10 +27,10 @@ end
local function request_reader(request, data, startpos)
if not data then
if request.body then
- request.callback(request.code, t_concat(request.body));
+ request.callback(request.code, t_concat(request.body), request);
else
-- Error.. connection was closed prematurely
- request.callback(0, "connection-closed");
+ request.callback(0, "connection-closed", request);
end
destroy_request(request);
return;
@@ -47,7 +47,7 @@ local function request_reader(request, data, startpos)
if request.havebodylength >= request.bodylength then
-- We have the body
if request.callback then
- request.callback(request.code, t_concat(request.body));
+ request.callback(request.code, t_concat(request.body), request);
end
end
print("", "Have "..request.havebodylength.." bytes out of "..request.bodylength);
@@ -78,14 +78,14 @@ local function request_reader(request, data, startpos)
print("Reading status...")
local http, code, text, linelen = data:match("^HTTP/(%S+) (%d+) (.-)\r\n()", startpos);
if not code then
- return request.callback(0, "invalid-status-line");
+ return request.callback(0, "invalid-status-line", request);
end
request.responsecode, request.responseversion = code, http;
if request.onlystatus or not expectbody(request, tonumber(code)) then
if request.callback then
- request.callback(code, nil);
+ request.callback(code, nil, request);
end
destroy_request(request);
return;