Subject: | PATCH: exposing Net::FTP->noop() as a method |
Just a quick patch to allow long lasting ftp sessions to call noop()
directly, instead of ->_NOOP()
Subject: | ftp_noop_method_support.patch |
diff -Naur old/libnet.cfg new/libnet.cfg
--- old/libnet.cfg 1970-01-01 10:00:00.000000000 +1000
+++ new/libnet.cfg 2012-02-19 09:42:32.345201508 +1100
@@ -0,0 +1,14 @@
+{
+ 'pop3_hosts' => [],
+ 'ph_hosts' => [],
+ 'inet_domain' => 'iinet.net.au',
+ 'time_hosts' => [],
+ 'daytime_hosts' => [],
+ 'smtp_hosts' => [],
+ 'test_exist' => 1,
+ 'test_hosts' => 1,
+ 'nntp_hosts' => [],
+ 'ftp_testhost' => 'localhost',
+ 'snpp_hosts' => [],
+ 'ftp_int_passive' => 1,
+}
diff -Naur old/Net/FTP.pm new/Net/FTP.pm
--- old/Net/FTP.pm 2009-10-27 12:02:44.000000000 +1100
+++ new/Net/FTP.pm 2012-02-19 09:47:18.088139585 +1100
@@ -155,6 +155,12 @@
}
+sub noop {
+ my $ftp = shift;
+
+ $ftp->_NOOP;
+}
+
sub DESTROY { }
@@ -1417,6 +1423,10 @@
If the connection is via a firewall then the C<authorize> method will
be called with no arguments.
+=item noop
+
+check if the ftp connection is still valid
+
=item authorize ( [AUTH [, RESP]])
This is a protocol used by some firewall ftp proxies. It is used
diff -Naur old/t/ftp.t new/t/ftp.t
--- old/t/ftp.t 2009-01-25 10:59:08.000000000 +1100
+++ new/t/ftp.t 2012-02-19 09:47:41.781459979 +1100
@@ -22,7 +22,7 @@
}
my $t = 1;
-print "1..7\n";
+print "1..9\n";
$ftp = Net::FTP->new($NetConfig{ftp_testhost})
or (print("not ok 1\n"), exit);
@@ -32,6 +32,9 @@
$ftp->login('anonymous') or die($ftp->message . "\n");
printf "ok %d\n",$t++;
+$ftp->noop() or die($ftp->message . "\n");
+printf "ok %d\n",$t++;
+
$ftp->pwd or do {
print STDERR $ftp->message,"\n";
print "not ";
@@ -71,3 +74,7 @@
};
printf "ok %d\n",$t++;
+
+$ftp->noop() and die($ftp->message . "\n");
+printf "ok %d\n",$t++;
+