From 16cf5ee1c91be4258f3d05d9dbd159ad48ad252f Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 20 Nov 2000 13:19:22 +0000 Subject: RETR seems to work too --- tests/ftpserver.pl | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/tests/ftpserver.pl b/tests/ftpserver.pl index b9efbb130..b884800e5 100644 --- a/tests/ftpserver.pl +++ b/tests/ftpserver.pl @@ -56,6 +56,7 @@ my %commandok = ( "USER" => "fresh", "PORT" => "loggedin", "TYPE" => "loggedin|twosock", "LIST" => "twosock", + "RETR" => "twosock", ); # initially, we're in 'fresh' state @@ -65,17 +66,19 @@ my %statechange = ( 'USER' => 'passwd', # USER goes to passwd state 'PASV' => 'twosock', # PASV goes to twosock ); +# this text is shown before the function specified below is run my %displaytext = ('USER' => '331 We are happy you popped in!', # output FTP line 'PASS' => '230 Welcome you silly person', 'PORT' => '200 You said PORT - I say FINE', 'TYPE' => '200 I modify TYPE as you wanted', - 'LIST' => '150 ASCII data connection for /bin/ls (193.15.23.1,59196) (0 bytes)', #150 Here comes a directory your way', + 'LIST' => '150 here comes a directory', ); # callback functions for certain commands my %commandfunc = ( 'PORT', \&PORT_command, 'LIST', \&LIST_command, - 'PASV', \&PASV_command); + 'PASV', \&PASV_command, + 'RETR', \&RETR_command); my $pid; @@ -105,6 +108,37 @@ sub LIST_command { return 0; } +sub RETR_command { + my $testno = $_[0]; + + logmsg "RETR test number $testno\n"; + + my $filename = "data/reply$testno.txt"; + + my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size, + $atime,$mtime,$ctime,$blksize,$blocks) + = stat($filename); + + if($size) { + + print "150 Binary data connection for $testno () ($size bytes).\r\n"; + + open(FILE, "<$filename"); + while() { + print KID_TO_WRITE $_; + # print STDERR "PASS: $_"; + } + close(KID_TO_WRITE); + + print "226 File transfer complete\r\n"; + } + else { + print "550 $testno: No such file or directory.\r\n"; + } + return 0; +} + + # < 220 pm1 FTP server (SunOS 5.7) ready. # > USER anonymous # < 331 Guest login ok, send ident as password. -- cgit v1.2.3