Skip to content

Commit 9f686b5

Browse files
rrevenanttmattnenterprise
authored andcommitted
Accept also a 250 response code for RETR, STOR and LIST commands (#76)
1 parent c392899 commit 9f686b5

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/ftp.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ impl FtpStream {
329329
self.read_response_in(&[status::ABOUT_TO_SEND, status::ALREADY_OPEN])
330330
.and_then(|_| reader(&mut data_stream))
331331
}.and_then(|res|
332-
self.read_response(status::CLOSING_DATA_CONNECTION).map(|_| res))
332+
self.read_response_in(&[status::CLOSING_DATA_CONNECTION,status::REQUESTED_FILE_ACTION_OK]).map(|_| res))
333333
}
334334

335335
/// Simple way to retr a file from the server. This stores the file in memory.
@@ -378,11 +378,12 @@ impl FtpStream {
378378
/// This stores a file on the server.
379379
pub fn put<R: Read>(&mut self, filename: &str, r: &mut R) -> Result<()> {
380380
try!(self.put_file(filename, r));
381-
self.read_response(status::CLOSING_DATA_CONNECTION).map(|_| ())
381+
self.read_response_in(&[status::CLOSING_DATA_CONNECTION,status::REQUESTED_FILE_ACTION_OK])
382+
.map(|_| ())
382383
}
383384

384385
/// Execute a command which returns list of strings in a separate stream
385-
fn list_command(&mut self, cmd: Cow<'static, str>, open_code: u32, close_code: u32) -> Result<Vec<String>> {
386+
fn list_command(&mut self, cmd: Cow<'static, str>, open_code: u32, close_code: &[u32]) -> Result<Vec<String>> {
386387
let mut lines: Vec<String> = Vec::new();
387388
{
388389
let mut data_stream = BufReader::new(try!(self.data_command(&cmd)));
@@ -398,7 +399,7 @@ impl FtpStream {
398399
}
399400
}
400401

401-
self.read_response(close_code).map(|_| lines)
402+
self.read_response_in(close_code).map(|_| lines)
402403
}
403404

404405
/// Execute `LIST` command which returns the detailed file listing in human readable format.
@@ -407,7 +408,7 @@ impl FtpStream {
407408
pub fn list(&mut self, pathname: Option<&str>) -> Result<Vec<String>> {
408409
let command = pathname.map_or("LIST\r\n".into(), |path| format!("LIST {}\r\n", path).into());
409410

410-
self.list_command(command, status::ABOUT_TO_SEND, status::CLOSING_DATA_CONNECTION)
411+
self.list_command(command, status::ABOUT_TO_SEND, &[status::CLOSING_DATA_CONNECTION,status::REQUESTED_FILE_ACTION_OK])
411412
}
412413

413414
/// Execute `NLST` command which returns the list of file names only.
@@ -416,7 +417,7 @@ impl FtpStream {
416417
pub fn nlst(&mut self, pathname: Option<&str>) -> Result<Vec<String>> {
417418
let command = pathname.map_or("NLST\r\n".into(), |path| format!("NLST {}\r\n", path).into());
418419

419-
self.list_command(command, status::ABOUT_TO_SEND, status::CLOSING_DATA_CONNECTION)
420+
self.list_command(command, status::ABOUT_TO_SEND, &[status::CLOSING_DATA_CONNECTION,status::REQUESTED_FILE_ACTION_OK])
420421
}
421422

422423
/// Retrieves the modification time of the file at `pathname` if it exists.

0 commit comments

Comments
 (0)