mirror of
https://github.com/lunarmodules/luasocket.git
synced 2024-12-26 04:28:20 +01:00
removed 2 locals, fixed http
This commit is contained in:
parent
9016e91238
commit
8bc5ba604e
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user