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.send{
[user = string,]
[password = string,]
[server = string,]
- [port = string,]
+ [port = number,]
[domain = string,]
[step = LTN12 pump step,]
}
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)
end
end
+--[[
local function chain2(f1, f2)
local ff1, ff2 = "", ""
return function(chunk)
@@ -55,6 +56,29 @@ local function chain2(f1, f2)
end
end
end
+]]
+
+local function chain2(f1, f2)
+ local co = coroutine.create(function(chunk)
+ while true do
+ local filtered1 = f1(chunk)
+ local filtered2 = f2(filtered1)
+ local done2 = filtered1 and ""
+ while true do
+ if filtered2 == "" or filtered2 == nil then break end
+ coroutine.yield(filtered2)
+ filtered2 = f2(done2)
+ end
+ if filtered1 == "" then chunk = coroutine.yield(filtered1)
+ elseif filtered1 == nil then return nil
+ else chunk = chunk and "" end
+ end
+ end)
+ return function(chunk)
+ local _, res = coroutine.resume(co, chunk)
+ return res
+ end
+end
-- chains a bunch of filters together
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()
end
-- create test file
-function create_b64test()
+local function create_b64test()
local f = assert(io.open(b64test, "wb"))
local t = {}
for j = 1, 100 do
@@ -282,8 +282,8 @@ end
local t = socket.gettime()
-identity_test()
create_b64test()
+identity_test()
encode_b64test()
decode_b64test()
compare_b64test()