Software /
code /
prosody
Comparison
net/http.lua @ 11017:1f41f38a92f7
Merge 0.11->trunk
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sat, 08 Aug 2020 13:14:11 +0100 |
parent | 10995:e18a913aed2d |
parent | 11016:5176d9f727f6 |
child | 11048:160308b4b384 |
comparison
equal
deleted
inserted
replaced
11014:05fefde93036 | 11017:1f41f38a92f7 |
---|---|
56 request.conn = nil; | 56 request.conn = nil; |
57 conn:close() | 57 conn:close() |
58 end | 58 end |
59 end | 59 end |
60 | 60 |
61 local function cancel_request(request, reason) | |
62 if request.callback then | |
63 request.callback(reason or "cancelled", 0, request); | |
64 request.callback = nil; | |
65 end | |
66 if request.conn then | |
67 destroy_request(request); | |
68 end | |
69 end | |
70 | |
61 local function request_reader(request, data, err) | 71 local function request_reader(request, data, err) |
62 if not request.parser then | 72 if not request.parser then |
63 local function error_cb(reason) | 73 local function error_cb(reason) |
64 if request.callback then | 74 if request.callback then |
65 request.callback(reason or "connection-closed", 0, request); | 75 request.callback(reason or "connection-closed", 0, request); |
105 log("debug", "Request '%s': Calling callback, status %s", req.id, code or "---"); | 115 log("debug", "Request '%s': Calling callback, status %s", req.id, code or "---"); |
106 return log_if_failed(req.id, xpcall(callback, handleerr, content, code, response, request)); | 116 return log_if_failed(req.id, xpcall(callback, handleerr, content, code, response, request)); |
107 end | 117 end |
108 req.reader = request_reader; | 118 req.reader = request_reader; |
109 req.state = "status"; | 119 req.state = "status"; |
120 req.cancel = cancel_request; | |
110 | 121 |
111 requests[req.conn] = req; | 122 requests[req.conn] = req; |
112 | 123 |
113 -- Validate certificate | 124 -- Validate certificate |
114 if not req.insecure and conn:ssl() then | 125 if not req.insecure and conn:ssl() then |
316 -- COMPAT | 327 -- COMPAT |
317 urlencode = util_http.urlencode; | 328 urlencode = util_http.urlencode; |
318 urldecode = util_http.urldecode; | 329 urldecode = util_http.urldecode; |
319 formencode = util_http.formencode; | 330 formencode = util_http.formencode; |
320 formdecode = util_http.formdecode; | 331 formdecode = util_http.formdecode; |
332 destroy_request = destroy_request; | |
321 }; | 333 }; |