aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiego Nehab <diego@tecgraf.puc-rio.br>2006-03-19 21:22:21 +0000
committerDiego Nehab <diego@tecgraf.puc-rio.br>2006-03-19 21:22:21 +0000
commit93806208c77607146f6f462426e380e732327ed5 (patch)
treeac0286d21b5d9343ab01afda6bc277e152936065
parent09ad4b299c59c3c5c6c442f0ee99f3c9e8dbe8ce (diff)
downloadluasocket-93806208c77607146f6f462426e380e732327ed5.tar.gz
luasocket-93806208c77607146f6f462426e380e732327ed5.tar.bz2
luasocket-93806208c77607146f6f462426e380e732327ed5.zip
Updates for 2.0.1 on the way.
-rw-r--r--TODO48
-rw-r--r--config2
-rw-r--r--etc/dispatch.lua21
-rw-r--r--src/http.lua2
-rw-r--r--test/dicttest.lua2
-rw-r--r--test/testmesg.lua13
6 files changed, 26 insertions, 62 deletions
diff --git a/TODO b/TODO
index 9586e23..ac4291c 100644
--- a/TODO
+++ b/TODO
@@ -1,25 +1,11 @@
1 1ftp send should return server replies?
2fix unix.c to return just a function 2make sure there are no object files in the distribution tarball
3get rid of setmetatable(, nil) since packages don't need this anymore in 3http handling of 100-continue, see DB patch
45.1 4DB ftp.lua bug.
5 5test unix.c to return just a function and works with require"unix"
6new instalation scheme??? 6get rid of setmetatable(, nil) since packages don't need this anymore in 5.1
7 7compat-5.1 novo
8test empty socket.select no windows. 8ajeitar pra lua-5.1
9
10bug by mathew percival?
11
12test it on Windows!!!
13
14leave code for losers that don't have nanosleep
15
16ftp.send/recv return bytes transfered?
17new scheme to choose family/protocol of object to create
18change ltn13 to make sure drawbacks are obvious
19 - check discussion
20use mike's "don't set to blocking before closing unless needed" patch?
21take a look at DB's smtp patch (add "extra argument" table)
22
23 9
24adicionar exemplos de expansão: pipe, local, named pipe 10adicionar exemplos de expansão: pipe, local, named pipe
25testar os options! 11testar os options!
@@ -27,21 +13,3 @@ testar os options!
27 - proteger get*by*.* com um mutex GLOBAL! 13 - proteger get*by*.* com um mutex GLOBAL!
28 - proteger ou atomizar o conjunto (timedout, receive), (timedout, send) 14 - proteger ou atomizar o conjunto (timedout, receive), (timedout, send)
29 - inet_ntoa também é uma merda. 15 - inet_ntoa também é uma merda.
30
31* protect doesn't catch errors by error and assert
32* BUG NO SET DO TINYIRC!!! SINISTRO.
33* _VERSION, _DEBUG, etc.
34* talk about new create field in HTTP, FTP and SMTP
35* talk about the non-blocking connect in the manual
36* think about how to extend http, ftp, smtp to use special send and receive
37* functions for non-blocking so they can be used in the context of the
38* dispatcher!
39* adjust manual for new sock:send returns.
40* think about a dispatcher.
41 * - it creates a server and receives a function that will do the work on
42 * received connections
43 * - this function is invoked with the client socket
44 * - it calls special send and receive functions that yield on timeout
45* arranjar um jeito de fazer multipart/alternative
46* what the hell does __unload do?
47 * it's there just in case someone wants to use it.
diff --git a/config b/config
index 0b2b492..f26b12e 100644
--- a/config
+++ b/config
@@ -21,7 +21,7 @@ LUALIB=-Llua-5.0.2/lib
21#------ 21#------
22# Compat-5.1 directory 22# Compat-5.1 directory
23# 23#
24COMPAT=compat-5.1r4 24COMPAT=compat-5.1r5
25 25
26#------ 26#------
27# Top of your Lua installation 27# Top of your Lua installation
diff --git a/etc/dispatch.lua b/etc/dispatch.lua
index dd76d6d..6f3855e 100644
--- a/etc/dispatch.lua
+++ b/etc/dispatch.lua
@@ -5,6 +5,7 @@
5-- RCS ID: $$ 5-- RCS ID: $$
6----------------------------------------------------------------------------- 6-----------------------------------------------------------------------------
7local base = _G 7local base = _G
8local table = require("table")
8local socket = require("socket") 9local socket = require("socket")
9local coroutine = require("coroutine") 10local coroutine = require("coroutine")
10module("dispatch") 11module("dispatch")
@@ -50,7 +51,7 @@ function socket.protect(f)
50 return function(...) 51 return function(...)
51 local co = coroutine.create(f) 52 local co = coroutine.create(f)
52 while true do 53 while true do
53 local results = {coroutine.resume(co, unpack(arg))} 54 local results = {coroutine.resume(co, base.unpack(arg))}
54 local status = table.remove(results, 1) 55 local status = table.remove(results, 1)
55 if not status then 56 if not status then
56 if type(results[1]) == 'table' then 57 if type(results[1]) == 'table' then
@@ -58,9 +59,9 @@ function socket.protect(f)
58 else error(results[1]) end 59 else error(results[1]) end
59 end 60 end
60 if coroutine.status(co) == "suspended" then 61 if coroutine.status(co) == "suspended" then
61 arg = {coroutine.yield(unpack(results))} 62 arg = {coroutine.yield(base.unpack(results))}
62 else 63 else
63 return unpack(results) 64 return base.unpack(results)
64 end 65 end
65 end 66 end
66 end 67 end
@@ -72,7 +73,7 @@ end
72local function newset() 73local function newset()
73 local reverse = {} 74 local reverse = {}
74 local set = {} 75 local set = {}
75 return setmetatable(set, {__index = { 76 return base.setmetatable(set, {__index = {
76 insert = function(set, value) 77 insert = function(set, value)
77 if not reverse[value] then 78 if not reverse[value] then
78 table.insert(set, value) 79 table.insert(set, value)
@@ -105,7 +106,7 @@ local function cowrap(dispatcher, tcp, error)
105 local metat = { __index = function(table, key) 106 local metat = { __index = function(table, key)
106 table[key] = function(...) 107 table[key] = function(...)
107 arg[1] = tcp 108 arg[1] = tcp
108 return tcp[key](unpack(arg)) 109 return tcp[key](base.unpack(arg))
109 end 110 end
110 return table[key] 111 return table[key]
111 end} 112 end}
@@ -202,7 +203,7 @@ local function cowrap(dispatcher, tcp, error)
202 dispatcher.receiving.cortn[tcp] = nil 203 dispatcher.receiving.cortn[tcp] = nil
203 return tcp:close() 204 return tcp:close()
204 end 205 end
205 return setmetatable(wrap, metat) 206 return base.setmetatable(wrap, metat)
206end 207end
207 208
208 209
@@ -253,17 +254,17 @@ function cometat.__index:step()
253 self.sending.set, 1) 254 self.sending.set, 1)
254 -- for all readable connections, resume their cortns and reschedule 255 -- for all readable connections, resume their cortns and reschedule
255 -- when they yield back to us 256 -- when they yield back to us
256 for _, tcp in ipairs(readable) do 257 for _, tcp in base.ipairs(readable) do
257 schedule(wakeup(self.receiving, tcp)) 258 schedule(wakeup(self.receiving, tcp))
258 end 259 end
259 -- for all writable connections, do the same 260 -- for all writable connections, do the same
260 for _, tcp in ipairs(writable) do 261 for _, tcp in base.ipairs(writable) do
261 schedule(wakeup(self.sending, tcp)) 262 schedule(wakeup(self.sending, tcp))
262 end 263 end
263 -- politely ask replacement I/O functions in idle cortns to 264 -- politely ask replacement I/O functions in idle cortns to
264 -- return reporting a timeout 265 -- return reporting a timeout
265 local now = socket.gettime() 266 local now = socket.gettime()
266 for tcp, stamp in pairs(self.stamp) do 267 for tcp, stamp in base.pairs(self.stamp) do
267 if tcp.class == "tcp{client}" and now - stamp > TIMEOUT then 268 if tcp.class == "tcp{client}" and now - stamp > TIMEOUT then
268 abort(self.sending, tcp) 269 abort(self.sending, tcp)
269 abort(self.receiving, tcp) 270 abort(self.receiving, tcp)
@@ -296,6 +297,6 @@ function handlert.coroutine()
296 function dispatcher.tcp() 297 function dispatcher.tcp()
297 return cowrap(dispatcher, socket.tcp()) 298 return cowrap(dispatcher, socket.tcp())
298 end 299 end
299 return setmetatable(dispatcher, cometat) 300 return base.setmetatable(dispatcher, cometat)
300end 301end
301 302
diff --git a/src/http.lua b/src/http.lua
index 081e156..e002a8c 100644
--- a/src/http.lua
+++ b/src/http.lua
@@ -268,7 +268,7 @@ function tredirect(reqt, location)
268 headers = reqt.headers, 268 headers = reqt.headers,
269 proxy = reqt.proxy, 269 proxy = reqt.proxy,
270 nredirects = (reqt.nredirects or 0) + 1, 270 nredirects = (reqt.nredirects or 0) + 1,
271 connect = reqt.connect 271 create = reqt.create
272 } 272 }
273 -- pass location header back as a hint we redirected 273 -- pass location header back as a hint we redirected
274 headers.location = headers.location or location 274 headers.location = headers.location or location
diff --git a/test/dicttest.lua b/test/dicttest.lua
index 9ab9c41..a0da2e1 100644
--- a/test/dicttest.lua
+++ b/test/dicttest.lua
@@ -1,3 +1,5 @@
1local dict = require"socket.dict" 1local dict = require"socket.dict"
2 2
3print(dict.get("dict://localhost/d:teste"))
4
3for i,v in pairs(dict.get("dict://localhost/d:teste")) do print(v) end 5for i,v in pairs(dict.get("dict://localhost/d:teste")) do print(v) end
diff --git a/test/testmesg.lua b/test/testmesg.lua
index 1dd9a97..5bec026 100644
--- a/test/testmesg.lua
+++ b/test/testmesg.lua
@@ -32,13 +32,6 @@ r, e = smtp.send{
32 port = 2525 32 port = 2525
33} 33}
34 34
35
36os.exit()
37
38
39
40
41
42-- creates a source to send a message with two parts. The first part is 35-- creates a source to send a message with two parts. The first part is
43-- plain text, the second part is a PNG image, encoded as base64. 36-- plain text, the second part is a PNG image, encoded as base64.
44source = smtp.message{ 37source = smtp.message{
@@ -67,13 +60,13 @@ source = smtp.message{
67 -- chunks are loaded into memory and translation happens on the fly. 60 -- chunks are loaded into memory and translation happens on the fly.
68 [2] = { 61 [2] = {
69 headers = { 62 headers = {
70 ["content-type"] = 'image/png; name="image.png"', 63 ["content-type"] = 'image/png; name="luasocket.png"',
71 ["content-disposition"] = 'attachment; filename="image.png"', 64 ["content-disposition"] = 'attachment; filename="luasocket.png"',
72 ["content-description"] = 'a beautiful image', 65 ["content-description"] = 'a beautiful image',
73 ["content-transfer-encoding"] = "BASE64" 66 ["content-transfer-encoding"] = "BASE64"
74 }, 67 },
75 body = ltn12.source.chain( 68 body = ltn12.source.chain(
76 ltn12.source.file(io.open("image.png", "rb")), 69 ltn12.source.file(io.open("luasocket.png", "rb")),
77 ltn12.filter.chain( 70 ltn12.filter.chain(
78 mime.encode("base64"), 71 mime.encode("base64"),
79 mime.wrap() 72 mime.wrap()