Changeset

11017:1f41f38a92f7

Merge 0.11->trunk
author Matthew Wild <mwild1@gmail.com>
date Sat, 08 Aug 2020 13:14:11 +0100
parents 11014:05fefde93036 (current diff) 11016:5176d9f727f6 (diff)
children 11019:d1604721b665
files net/http.lua
diffstat 1 files changed, 12 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/net/http.lua	Sat Jul 25 17:26:11 2020 +0200
+++ b/net/http.lua	Sat Aug 08 13:14:11 2020 +0100
@@ -58,6 +58,16 @@
 	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 @@
 	end
 	req.reader = request_reader;
 	req.state = "status";
+	req.cancel = cancel_request;
 
 	requests[req.conn] = req;
 
@@ -318,4 +329,5 @@
 	urldecode = util_http.urldecode;
 	formencode = util_http.formencode;
 	formdecode = util_http.formdecode;
+	destroy_request = destroy_request;
 };