From 74fcf735d9de0347303a9da834e63b0979189d4f Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Fri, 23 Feb 2018 16:20:45 +0000 Subject: net.http: Remove use of 'conn' (raw socket object returned by addclient) --- net/http.lua | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'net') 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; -- cgit v1.2.3