[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: copas and luasec question
- From: startx <startx@...>
- Date: Wed, 28 Sep 2011 10:28:21 +0100
hello.
i tried to hook up luasocket, copas and luasec by wrapping the socket
connection in ssl before handing it over to copas.
however, i currently run into a problem with the code below: when a
request comes in, the handshake works fine ( i can get the HTTP GET
line from the client,
but skt:send(response) is not executed until i stop (kill) the
application , i.e. the handler seems to hang just before
skt:send() and the client seems to wait forever.
copas works fine with the same code without ssl.wrap ( it sends the
response immediately) , also ssl works totally fine if i run it single threaded
without copas.
am i missing something obvious?
--- example:
require "socket"
require "ssl"
require "copas"
params = {
mode = "server",
protocol = "sslv23",
certificate = "./apache.crt",
key = "./apache.key",
verify = "none",
}
local function handler(skt, host, port)
print(host, port)
local line, err = skt:receive()
print(line, err)
local response = "HTTP/1.1 200/OK\r\nContent-Type: text/html\n\nhello world!\n"
skt:send(response)
end
copas.addserver(
assert(socket.bind("*", 8888)),
function(skt)
local host, port = skt:getpeername()
skt = ssl.wrap(skt, params)
skt:dohandshake()
return handler(copas.wrap(skt), host, port)
end )
copas.loop()