Updates for 2.0.1 on the way.

master
Diego Nehab 2006-03-19 21:22:21 +00:00
parent 09ad4b299c
commit 93806208c7
6 changed files with 26 additions and 62 deletions

48
TODO
View File

@ -1,25 +1,11 @@
fix unix.c to return just a function
get rid of setmetatable(, nil) since packages don't need this anymore in
5.1
new instalation scheme???
test empty socket.select no windows.
bug by mathew percival?
test it on Windows!!!
leave code for losers that don't have nanosleep
ftp.send/recv return bytes transfered?
new scheme to choose family/protocol of object to create
change ltn13 to make sure drawbacks are obvious
- check discussion
use mike's "don't set to blocking before closing unless needed" patch?
take a look at DB's smtp patch (add "extra argument" table)
ftp send should return server replies?
make sure there are no object files in the distribution tarball
http handling of 100-continue, see DB patch
DB ftp.lua bug.
test unix.c to return just a function and works with require"unix"
get rid of setmetatable(, nil) since packages don't need this anymore in 5.1
compat-5.1 novo
ajeitar pra lua-5.1
adicionar exemplos de expansão: pipe, local, named pipe
testar os options!
@ -27,21 +13,3 @@ testar os options!
- proteger get*by*.* com um mutex GLOBAL!
- proteger ou atomizar o conjunto (timedout, receive), (timedout, send)
- inet_ntoa também é uma merda.
* protect doesn't catch errors by error and assert
* BUG NO SET DO TINYIRC!!! SINISTRO.
* _VERSION, _DEBUG, etc.
* talk about new create field in HTTP, FTP and SMTP
* talk about the non-blocking connect in the manual
* think about how to extend http, ftp, smtp to use special send and receive
* functions for non-blocking so they can be used in the context of the
* dispatcher!
* adjust manual for new sock:send returns.
* think about a dispatcher.
* - it creates a server and receives a function that will do the work on
* received connections
* - this function is invoked with the client socket
* - it calls special send and receive functions that yield on timeout
* arranjar um jeito de fazer multipart/alternative
* what the hell does __unload do?
* it's there just in case someone wants to use it.

2
config
View File

@ -21,7 +21,7 @@ LUALIB=-Llua-5.0.2/lib
#------
# Compat-5.1 directory
#
COMPAT=compat-5.1r4
COMPAT=compat-5.1r5
#------
# Top of your Lua installation

View File

@ -5,6 +5,7 @@
-- RCS ID: $$
-----------------------------------------------------------------------------
local base = _G
local table = require("table")
local socket = require("socket")
local coroutine = require("coroutine")
module("dispatch")
@ -50,7 +51,7 @@ function socket.protect(f)
return function(...)
local co = coroutine.create(f)
while true do
local results = {coroutine.resume(co, unpack(arg))}
local results = {coroutine.resume(co, base.unpack(arg))}
local status = table.remove(results, 1)
if not status then
if type(results[1]) == 'table' then
@ -58,9 +59,9 @@ function socket.protect(f)
else error(results[1]) end
end
if coroutine.status(co) == "suspended" then
arg = {coroutine.yield(unpack(results))}
arg = {coroutine.yield(base.unpack(results))}
else
return unpack(results)
return base.unpack(results)
end
end
end
@ -72,7 +73,7 @@ end
local function newset()
local reverse = {}
local set = {}
return setmetatable(set, {__index = {
return base.setmetatable(set, {__index = {
insert = function(set, value)
if not reverse[value] then
table.insert(set, value)
@ -105,7 +106,7 @@ local function cowrap(dispatcher, tcp, error)
local metat = { __index = function(table, key)
table[key] = function(...)
arg[1] = tcp
return tcp[key](unpack(arg))
return tcp[key](base.unpack(arg))
end
return table[key]
end}
@ -202,7 +203,7 @@ local function cowrap(dispatcher, tcp, error)
dispatcher.receiving.cortn[tcp] = nil
return tcp:close()
end
return setmetatable(wrap, metat)
return base.setmetatable(wrap, metat)
end
@ -253,17 +254,17 @@ function cometat.__index:step()
self.sending.set, 1)
-- for all readable connections, resume their cortns and reschedule
-- when they yield back to us
for _, tcp in ipairs(readable) do
for _, tcp in base.ipairs(readable) do
schedule(wakeup(self.receiving, tcp))
end
-- for all writable connections, do the same
for _, tcp in ipairs(writable) do
for _, tcp in base.ipairs(writable) do
schedule(wakeup(self.sending, tcp))
end
-- politely ask replacement I/O functions in idle cortns to
-- return reporting a timeout
local now = socket.gettime()
for tcp, stamp in pairs(self.stamp) do
for tcp, stamp in base.pairs(self.stamp) do
if tcp.class == "tcp{client}" and now - stamp > TIMEOUT then
abort(self.sending, tcp)
abort(self.receiving, tcp)
@ -296,6 +297,6 @@ function handlert.coroutine()
function dispatcher.tcp()
return cowrap(dispatcher, socket.tcp())
end
return setmetatable(dispatcher, cometat)
return base.setmetatable(dispatcher, cometat)
end

View File

@ -268,7 +268,7 @@ function tredirect(reqt, location)
headers = reqt.headers,
proxy = reqt.proxy,
nredirects = (reqt.nredirects or 0) + 1,
connect = reqt.connect
create = reqt.create
}
-- pass location header back as a hint we redirected
headers.location = headers.location or location

View File

@ -1,3 +1,5 @@
local dict = require"socket.dict"
print(dict.get("dict://localhost/d:teste"))
for i,v in pairs(dict.get("dict://localhost/d:teste")) do print(v) end

View File

@ -32,13 +32,6 @@ r, e = smtp.send{
port = 2525
}
os.exit()
-- creates a source to send a message with two parts. The first part is
-- plain text, the second part is a PNG image, encoded as base64.
source = smtp.message{
@ -67,13 +60,13 @@ source = smtp.message{
-- chunks are loaded into memory and translation happens on the fly.
[2] = {
headers = {
["content-type"] = 'image/png; name="image.png"',
["content-disposition"] = 'attachment; filename="image.png"',
["content-type"] = 'image/png; name="luasocket.png"',
["content-disposition"] = 'attachment; filename="luasocket.png"',
["content-description"] = 'a beautiful image',
["content-transfer-encoding"] = "BASE64"
},
body = ltn12.source.chain(
ltn12.source.file(io.open("image.png", "rb")),
ltn12.source.file(io.open("luasocket.png", "rb")),
ltn12.filter.chain(
mime.encode("base64"),
mime.wrap()