diff options
author | Diego Nehab <diego@tecgraf.puc-rio.br> | 2004-11-17 04:55:57 +0000 |
---|---|---|
committer | Diego Nehab <diego@tecgraf.puc-rio.br> | 2004-11-17 04:55:57 +0000 |
commit | bdc3e241bb61a8bbf64353cb4090b4da417b06b0 (patch) | |
tree | 3c34621efe4294c6bad590e34b7646ef1d1c7a83 | |
parent | 3700bf65b71c5ce24cdd9aa523366daad6dd5fe2 (diff) | |
download | luasocket-bdc3e241bb61a8bbf64353cb4090b4da417b06b0.tar.gz luasocket-bdc3e241bb61a8bbf64353cb4090b4da417b06b0.tar.bz2 luasocket-bdc3e241bb61a8bbf64353cb4090b4da417b06b0.zip |
Little bug in manual.
-rw-r--r-- | doc/smtp.html | 2 | ||||
-rw-r--r-- | src/ltn12.lua | 24 | ||||
-rw-r--r-- | test/mimetest.lua | 4 |
3 files changed, 27 insertions, 3 deletions
diff --git a/doc/smtp.html b/doc/smtp.html index b975045..4a9aaac 100644 --- a/doc/smtp.html +++ b/doc/smtp.html | |||
@@ -122,7 +122,7 @@ smtp.<b>send{</b><br> | |||
122 | [user = <i>string</i>,]<br> | 122 | [user = <i>string</i>,]<br> |
123 | [password = <i>string</i>,]<br> | 123 | [password = <i>string</i>,]<br> |
124 | [server = <i>string</i>,]<br> | 124 | [server = <i>string</i>,]<br> |
125 | [port = <i>string</i>,]<br> | 125 | [port = <i>number</i>,]<br> |
126 | [domain = <i>string</i>,]<br> | 126 | [domain = <i>string</i>,]<br> |
127 | [step = <i>LTN12 pump step</i>,]<br> | 127 | [step = <i>LTN12 pump step</i>,]<br> |
128 | <b>}</b> | 128 | <b>}</b> |
diff --git a/src/ltn12.lua b/src/ltn12.lua index 9917ce8..ed39ec8 100644 --- a/src/ltn12.lua +++ b/src/ltn12.lua | |||
@@ -31,6 +31,7 @@ function filter.cycle(low, ctx, extra) | |||
31 | end | 31 | end |
32 | end | 32 | end |
33 | 33 | ||
34 | --[[ | ||
34 | local function chain2(f1, f2) | 35 | local function chain2(f1, f2) |
35 | local ff1, ff2 = "", "" | 36 | local ff1, ff2 = "", "" |
36 | return function(chunk) | 37 | return function(chunk) |
@@ -55,6 +56,29 @@ local function chain2(f1, f2) | |||
55 | end | 56 | end |
56 | end | 57 | end |
57 | end | 58 | end |
59 | ]] | ||
60 | |||
61 | local function chain2(f1, f2) | ||
62 | local co = coroutine.create(function(chunk) | ||
63 | while true do | ||
64 | local filtered1 = f1(chunk) | ||
65 | local filtered2 = f2(filtered1) | ||
66 | local done2 = filtered1 and "" | ||
67 | while true do | ||
68 | if filtered2 == "" or filtered2 == nil then break end | ||
69 | coroutine.yield(filtered2) | ||
70 | filtered2 = f2(done2) | ||
71 | end | ||
72 | if filtered1 == "" then chunk = coroutine.yield(filtered1) | ||
73 | elseif filtered1 == nil then return nil | ||
74 | else chunk = chunk and "" end | ||
75 | end | ||
76 | end) | ||
77 | return function(chunk) | ||
78 | local _, res = coroutine.resume(co, chunk) | ||
79 | return res | ||
80 | end | ||
81 | end | ||
58 | 82 | ||
59 | -- chains a bunch of filters together | 83 | -- chains a bunch of filters together |
60 | function filter.chain(...) | 84 | function filter.chain(...) |
diff --git a/test/mimetest.lua b/test/mimetest.lua index 89926d8..834d99f 100644 --- a/test/mimetest.lua +++ b/test/mimetest.lua | |||
@@ -187,7 +187,7 @@ local function cleanup_qptest() | |||
187 | end | 187 | end |
188 | 188 | ||
189 | -- create test file | 189 | -- create test file |
190 | function create_b64test() | 190 | local function create_b64test() |
191 | local f = assert(io.open(b64test, "wb")) | 191 | local f = assert(io.open(b64test, "wb")) |
192 | local t = {} | 192 | local t = {} |
193 | for j = 1, 100 do | 193 | for j = 1, 100 do |
@@ -282,8 +282,8 @@ end | |||
282 | 282 | ||
283 | local t = socket.gettime() | 283 | local t = socket.gettime() |
284 | 284 | ||
285 | identity_test() | ||
286 | create_b64test() | 285 | create_b64test() |
286 | identity_test() | ||
287 | encode_b64test() | 287 | encode_b64test() |
288 | decode_b64test() | 288 | decode_b64test() |
289 | compare_b64test() | 289 | compare_b64test() |