aboutsummaryrefslogtreecommitdiffstats
path: root/net/http.lua
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2020-08-08 13:14:11 +0100
committerMatthew Wild <mwild1@gmail.com>2020-08-08 13:14:11 +0100
commitee983242db48900938d096b1f86130b85099c288 (patch)
tree592338b8cd7ca65246d062e66c4c1e6fac21b74b /net/http.lua
parent2d4006b1c87861ed8f2442c214ad9d8c96f7b771 (diff)
parentf3796f6c5261135d68ebd345690836e40fd6b562 (diff)
downloadprosody-ee983242db48900938d096b1f86130b85099c288.tar.gz
prosody-ee983242db48900938d096b1f86130b85099c288.zip
Merge 0.11->trunk
Diffstat (limited to 'net/http.lua')
-rw-r--r--net/http.lua12
1 files changed, 12 insertions, 0 deletions
diff --git a/net/http.lua b/net/http.lua
index 17c755cf..f1055840 100644
--- a/net/http.lua
+++ b/net/http.lua
@@ -58,6 +58,16 @@ local function destroy_request(request)
end
end
+local function cancel_request(request, reason)
+ if request.callback then
+ request.callback(reason or "cancelled", 0, request);
+ request.callback = nil;
+ end
+ if request.conn then
+ destroy_request(request);
+ end
+end
+
local function request_reader(request, data, err)
if not request.parser then
local function error_cb(reason)
@@ -107,6 +117,7 @@ function listener.onconnect(conn)
end
req.reader = request_reader;
req.state = "status";
+ req.cancel = cancel_request;
requests[req.conn] = req;
@@ -318,4 +329,5 @@ return {
urldecode = util_http.urldecode;
formencode = util_http.formencode;
formdecode = util_http.formdecode;
+ destroy_request = destroy_request;
};