From 8bc5ba604ec089c0002c1cad00f43a11ada0a29a Mon Sep 17 00:00:00 2001 From: Thijs Schreijer Date: Mon, 16 Mar 2015 17:06:32 +0100 Subject: [PATCH] removed 2 locals, fixed http --- src/ftp.lua | 8 ++++++-- src/http.lua | 2 +- src/smtp.lua | 9 ++++++--- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/ftp.lua b/src/ftp.lua index 1e9bc02..a894c1c 100644 --- a/src/ftp.lua +++ b/src/ftp.lua @@ -35,8 +35,12 @@ _M.PASSWORD = "anonymous@anonymous.org" local metat = { __index = {} } function _M.open(params) - local c = function() return params:create() end -- wrap create as a method call - local tp = socket.try(tp.connect(params.server, params.port or _M.PORT, _M.TIMEOUT, c)) + local tp = socket.try(tp.connect( + params.server, + params.port or _M.PORT, + _M.TIMEOUT, + function() return params:create() end -- wrap create as a method call + )) local f = base.setmetatable({ tp = tp }, metat) -- make sure everything gets closed in an exception f.try = socket.newtry(function() f:close() end) diff --git a/src/http.lua b/src/http.lua index cecb3b4..d926e72 100644 --- a/src/http.lua +++ b/src/http.lua @@ -352,7 +352,7 @@ end _M.request = socket.protect(function(reqt, body) if base.type(reqt) == "string" then reqt = _M.parseRequest(reqt, body) - local t, code, headers, status = reqt.target, socket.skip(1, trequest(reqt)) + local t, code, headers, status = reqt.target, socket.skip(1, _M.request(reqt)) return table.concat(t), code, headers, status else reqt.create = reqt.create or socket.tcp diff --git a/src/smtp.lua b/src/smtp.lua index e60791f..ea52873 100644 --- a/src/smtp.lua +++ b/src/smtp.lua @@ -114,9 +114,12 @@ function metat.__index:send(mailt) end function _M.open(mailt) - local c = function() return mailt:create() end -- wrap to do a method call - local tp = socket.try(tp.connect(mailt.server or _M.SERVER, mailt.port or _M.PORT, - _M.TIMEOUT, c)) + local tp = socket.try(tp.connect( + mailt.server or _M.SERVER, + mailt.port or _M.PORT, + _M.TIMEOUT, + function() return mailt:create() end -- wrap to do a method call + )) local s = base.setmetatable({tp = tp}, metat) -- make sure tp is closed if we get an exception s.try = socket.newtry(function()