diff options
| author | Diego Nehab <diego@tecgraf.puc-rio.br> | 2004-05-26 04:58:32 +0000 |
|---|---|---|
| committer | Diego Nehab <diego@tecgraf.puc-rio.br> | 2004-05-26 04:58:32 +0000 |
| commit | bf738a03368b8de9c574d9631f131c5a520acf7b (patch) | |
| tree | a65c512ce4601b056417ff7154ebdc254d762054 /src | |
| parent | 4b7c2db4b7109bf57abd1b76abf24eba27f51aa1 (diff) | |
| download | luasocket-bf738a03368b8de9c574d9631f131c5a520acf7b.tar.gz luasocket-bf738a03368b8de9c574d9631f131c5a520acf7b.tar.bz2 luasocket-bf738a03368b8de9c574d9631f131c5a520acf7b.zip | |
Working with in the manual.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ftp.lua | 2 | ||||
| -rw-r--r-- | src/smtp.lua | 6 | ||||
| -rw-r--r-- | src/tp.lua | 10 |
3 files changed, 7 insertions, 11 deletions
diff --git a/src/ftp.lua b/src/ftp.lua index ee1f9aa..306b77f 100644 --- a/src/ftp.lua +++ b/src/ftp.lua | |||
| @@ -114,7 +114,7 @@ function metat.__index:send(sendt) | |||
| 114 | if err then data:close() end | 114 | if err then data:close() end |
| 115 | return ret, err | 115 | return ret, err |
| 116 | end | 116 | end |
| 117 | local sink = socket.sink("close-when-empty", data) | 117 | local sink = socket.sink("close-when-done", data) |
| 118 | socket.try(ltn12.pump.all(sendt.source, sink, checkstep)) | 118 | socket.try(ltn12.pump.all(sendt.source, sink, checkstep)) |
| 119 | if string.find(code, "1..") then socket.try(self.tp:check("2..")) end | 119 | if string.find(code, "1..") then socket.try(self.tp:check("2..")) end |
| 120 | return 1 | 120 | return 1 |
diff --git a/src/smtp.lua b/src/smtp.lua index 6ddeaae..8e672a0 100644 --- a/src/smtp.lua +++ b/src/smtp.lua | |||
| @@ -51,10 +51,10 @@ function metat.__index:rcpt(to) | |||
| 51 | return socket.try(self.tp:check("2..")) | 51 | return socket.try(self.tp:check("2..")) |
| 52 | end | 52 | end |
| 53 | 53 | ||
| 54 | function metat.__index:data(src) | 54 | function metat.__index:data(src, step) |
| 55 | socket.try(self.tp:command("DATA")) | 55 | socket.try(self.tp:command("DATA")) |
| 56 | socket.try(self.tp:check("3..")) | 56 | socket.try(self.tp:check("3..")) |
| 57 | socket.try(self.tp:source(src)) | 57 | socket.try(self.tp:source(src, step)) |
| 58 | socket.try(self.tp:send("\r\n.\r\n")) | 58 | socket.try(self.tp:send("\r\n.\r\n")) |
| 59 | return socket.try(self.tp:check("2..")) | 59 | return socket.try(self.tp:check("2..")) |
| 60 | end | 60 | end |
| @@ -78,7 +78,7 @@ function metat.__index:send(mailt) | |||
| 78 | else | 78 | else |
| 79 | self:rcpt(mailt.rcpt) | 79 | self:rcpt(mailt.rcpt) |
| 80 | end | 80 | end |
| 81 | self:data(ltn12.source.chain(mailt.source, stuff())) | 81 | self:data(ltn12.source.chain(mailt.source, stuff()), mailt.step) |
| 82 | end | 82 | end |
| 83 | 83 | ||
| 84 | function open(server, port) | 84 | function open(server, port) |
| @@ -87,13 +87,9 @@ function metat.__index:getcontrol() | |||
| 87 | return self.control | 87 | return self.control |
| 88 | end | 88 | end |
| 89 | 89 | ||
| 90 | function metat.__index:source(src, instr) | 90 | function metat.__index:source(source, step) |
| 91 | while true do | 91 | local sink = socket.sink("keep-open", self.control) |
| 92 | local chunk, err = src() | 92 | return ltn12.pump.all(source, sink, step or ltn12.pump.step) |
| 93 | if not chunk then return not err, err end | ||
| 94 | local ret, err = self.control:send(chunk) | ||
| 95 | if not ret then return nil, err end | ||
| 96 | end | ||
| 97 | end | 93 | end |
| 98 | 94 | ||
| 99 | -- closes the underlying control | 95 | -- closes the underlying control |
