aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2018-02-23 16:20:45 +0000
committerMatthew Wild <mwild1@gmail.com>2018-02-23 16:20:45 +0000
commita761524e2856b41b8c42529f833accc70d10d693 (patch)
tree229a480960e2d6755733ebd7be96295affcf4456
parent61c6bb76de017098bc74e77310d2689845c22b5a (diff)
downloadprosody-a761524e2856b41b8c42529f833accc70d10d693.tar.gz
prosody-a761524e2856b41b8c42529f833accc70d10d693.zip
net.http: Remove use of 'conn' (raw socket object returned by addclient)
-rw-r--r--net/http.lua19
1 files changed, 10 insertions, 9 deletions
diff --git a/net/http.lua b/net/http.lua
index 8364a104..cda1496c 100644
--- a/net/http.lua
+++ b/net/http.lua
@@ -100,9 +100,10 @@ function listener.ondetach(conn)
end
local function destroy_request(request)
- if request.conn then
+ local conn = request.conn;
+ if conn then
request.conn = nil;
- request.handler:close()
+ conn:close()
end
end
@@ -221,14 +222,14 @@ local function request(self, u, ex, callback)
sslctx = ex and ex.sslctx or self.options and self.options.sslctx;
end
- local handler, conn = server.addclient(host, port_number, listener, "*a", sslctx)
+ local handler, ret = server.addclient(host, port_number, listener, "*a", sslctx)
if not handler then
- self.events.fire_event("request-connection-error", { http = self, request = req, url = u, err = conn });
- callback(conn, 0, req);
- return nil, conn;
+ self.events.fire_event("request-connection-error", { http = self, request = req, url = u, err = ret });
+ callback(ret, 0, req);
+ return nil, ret;
end
- req.handler, req.conn = handler, conn
- req.write = function (...) return req.handler:write(...); end
+ req.conn = handler
+ req.write = function (...) return req.conn:write(...); end
req.callback = function (content, code, response, request)
do
@@ -243,7 +244,7 @@ local function request(self, u, ex, callback)
req.reader = request_reader;
req.state = "status";
- requests[req.handler] = req;
+ requests[req.conn] = req;
self.events.fire_event("request", { http = self, request = req, url = u });
return req;