aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2000-11-20 13:19:22 +0000
committerDaniel Stenberg <daniel@haxx.se>2000-11-20 13:19:22 +0000
commit16cf5ee1c91be4258f3d05d9dbd159ad48ad252f (patch)
tree3ba07be0bba05daa917411162c218e9aa5c62d3d
parenta7937ed49c8f201444323b8a721e1d04e0306105 (diff)
RETR seems to work too
-rw-r--r--tests/ftpserver.pl38
1 files 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(<FILE>) {
+ 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.