mirror of
https://github.com/lunarmodules/luasocket.git
synced 2024-12-26 12:28:21 +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 = {} }
|
local metat = { __index = {} }
|
||||||
|
|
||||||
function _M.open(params)
|
function _M.open(params)
|
||||||
local c = function() return params:create() end -- wrap create as a method call
|
local tp = socket.try(tp.connect(
|
||||||
local tp = socket.try(tp.connect(params.server, params.port or _M.PORT, _M.TIMEOUT, c))
|
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)
|
local f = base.setmetatable({ tp = tp }, metat)
|
||||||
-- make sure everything gets closed in an exception
|
-- make sure everything gets closed in an exception
|
||||||
f.try = socket.newtry(function() f:close() end)
|
f.try = socket.newtry(function() f:close() end)
|
||||||
|
@ -352,7 +352,7 @@ end
|
|||||||
_M.request = socket.protect(function(reqt, body)
|
_M.request = socket.protect(function(reqt, body)
|
||||||
if base.type(reqt) == "string" then
|
if base.type(reqt) == "string" then
|
||||||
reqt = _M.parseRequest(reqt, body)
|
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
|
return table.concat(t), code, headers, status
|
||||||
else
|
else
|
||||||
reqt.create = reqt.create or socket.tcp
|
reqt.create = reqt.create or socket.tcp
|
||||||
|
@ -114,9 +114,12 @@ function metat.__index:send(mailt)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function _M.open(mailt)
|
function _M.open(mailt)
|
||||||
local c = function() return mailt:create() end -- wrap to do a method call
|
local tp = socket.try(tp.connect(
|
||||||
local tp = socket.try(tp.connect(mailt.server or _M.SERVER, mailt.port or _M.PORT,
|
mailt.server or _M.SERVER,
|
||||||
_M.TIMEOUT, c))
|
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)
|
local s = base.setmetatable({tp = tp}, metat)
|
||||||
-- make sure tp is closed if we get an exception
|
-- make sure tp is closed if we get an exception
|
||||||
s.try = socket.newtry(function()
|
s.try = socket.newtry(function()
|
||||||
|
Loading…
Reference in New Issue
Block a user