diff options
author | Matthew Wild <mwild1@gmail.com> | 2018-02-23 16:20:45 +0000 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2018-02-23 16:20:45 +0000 |
commit | 74fcf735d9de0347303a9da834e63b0979189d4f (patch) | |
tree | 229a480960e2d6755733ebd7be96295affcf4456 /net | |
parent | 65abcbb563533e674893c449cde8c9418424947e (diff) | |
download | prosody-74fcf735d9de0347303a9da834e63b0979189d4f.tar.gz prosody-74fcf735d9de0347303a9da834e63b0979189d4f.zip |
net.http: Remove use of 'conn' (raw socket object returned by addclient)
Diffstat (limited to 'net')
-rw-r--r-- | net/http.lua | 19 |
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; |