aboutsummaryrefslogtreecommitdiffstats
path: root/net/http.lua
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2013-04-18 00:10:52 +0100
committerMatthew Wild <mwild1@gmail.com>2013-04-18 00:10:52 +0100
commit18a0ca2f3d9e1be916f764538fab30a9eabc7716 (patch)
tree0604a6d66c0c755bf29a09127cce1c4ce854f6ac /net/http.lua
parent3b6ed12bb6225d37e234c6c994b2114f1e5e0b84 (diff)
parent8432300448438ac440333c9b371826ace1fd7e86 (diff)
downloadprosody-18a0ca2f3d9e1be916f764538fab30a9eabc7716.tar.gz
prosody-18a0ca2f3d9e1be916f764538fab30a9eabc7716.zip
Merge 0.9->trunk
Diffstat (limited to 'net/http.lua')
-rw-r--r--net/http.lua19
1 files changed, 12 insertions, 7 deletions
diff --git a/net/http.lua b/net/http.lua
index 4eb4a2ac..639ecf6a 100644
--- a/net/http.lua
+++ b/net/http.lua
@@ -66,24 +66,29 @@ end
function listener.ondisconnect(conn, err)
local request = requests[conn];
if request and request.conn then
- request:reader(nil);
+ request:reader(nil, err);
end
requests[conn] = nil;
end
-local function request_reader(request, data)
+local function request_reader(request, data, err)
if not request.parser then
- if not data then return; end
- local function success_cb(r)
+ local function error_cb(reason)
if request.callback then
- request.callback(r.body, r.code, r, request);
+ request.callback(reason or "connection-closed", 0, request);
request.callback = nil;
end
destroy_request(request);
end
- local function error_cb(r)
+
+ if not data then
+ error_cb(err);
+ return;
+ end
+
+ local function success_cb(r)
if request.callback then
- request.callback(r or "connection-closed", 0, request);
+ request.callback(r.body, r.code, r, request);
request.callback = nil;
end
destroy_request(request);