[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: https support (silightly different approach)
- From: Norbert Kiesel <nkiesel@...>
- Date: Mon, 09 Mar 2009 18:07:56 -0700
Hi,
I just subscribed so I can't continue the thread "Q: luasocket https
client?" started on 2009-02-13. I faced the same problem some time back
(actually for allowing HTTPS SOAP calls), but I added an optional
parameter to socket.http.open:
function open(host, port, create, security_context)
-- create socket with user connect function, or with default
local c = socket.try((create or socket.tcp)())
local h = base.setmetatable({ c = c }, metat)
-- create finalized try
h.try = socket.newtry(function() h:close() end)
-- set timeout before connecting
h.try(c:settimeout(TIMEOUT))
h.try(c:connect(host, port or PORT))
if security_context then
h.c = h.try(ssl.wrap(c, security_context))
h.try(h.c:dohandshake())
end
-- here everything worked
return h
end
security_context id the normal context passed to ssl.wrap
This way I can make both HTTP and HTTPS calls.
</nk>