diff options
author | moteus <mimir@newmail.ru> | 2013-05-30 11:01:07 +0400 |
---|---|---|
committer | moteus <mimir@newmail.ru> | 2013-05-30 11:01:07 +0400 |
commit | 00a06857c9c602285e21998e2a9dfef74ad8c525 (patch) | |
tree | d187642c7c34f1d88739d8d231b8df9b52c907d4 | |
parent | 5341131cd07bf4f66ce242980b5f3cfbbf45ea12 (diff) | |
download | luasocket-00a06857c9c602285e21998e2a9dfef74ad8c525.tar.gz luasocket-00a06857c9c602285e21998e2a9dfef74ad8c525.tar.bz2 luasocket-00a06857c9c602285e21998e2a9dfef74ad8c525.zip |
Fix. recive 2xx while ftp.get cause timeout error
In this example:
>Client send: MDTM test.txt
>Server response: 213 20120824120909
Because FTP server do not open new channel (2XX response)
and LuaSocket try open new channel we get timeout.
```lua
local ftp = require "socket.ftp"
local ltn12 = require "ltn12"
local url = require("socket.url")
local URL = "ftp://USER:TEST@127.0.0.1";
local CMD = 'MDTM test.txt';
-- get timeout
ftp.get{
url = URL;
command = CMD;
sink = ltn12.sink.table{};
}
-- or we can use ftp.command
ftp.command{
url = URL;
command = URL,
check = function(...)
local status, data = ...
return true
end;
}
```
-rw-r--r-- | src/ftp.lua | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/ftp.lua b/src/ftp.lua index 714b388..ea1145b 100644 --- a/src/ftp.lua +++ b/src/ftp.lua | |||
@@ -142,7 +142,11 @@ function metat.__index:receive(recvt) | |||
142 | if argument == "" then argument = nil end | 142 | if argument == "" then argument = nil end |
143 | local command = recvt.command or "retr" | 143 | local command = recvt.command or "retr" |
144 | self.try(self.tp:command(command, argument)) | 144 | self.try(self.tp:command(command, argument)) |
145 | local code = self.try(self.tp:check{"1..", "2.."}) | 145 | local code,reply = self.try(self.tp:check{"1..", "2.."}) |
146 | if (code >= 200) and (code <= 299) then | ||
147 | recvt.sink(reply) | ||
148 | return 1 | ||
149 | end | ||
146 | if not self.pasvt then self:portconnect() end | 150 | if not self.pasvt then self:portconnect() end |
147 | local source = socket.source("until-closed", self.data) | 151 | local source = socket.source("until-closed", self.data) |
148 | local step = recvt.step or ltn12.pump.step | 152 | local step = recvt.step or ltn12.pump.step |