More ftp weirdness
Adam Clark (adamc@cnet.com)
Mon, 27 Jul 1998 10:56:21 -0700
FYI --
The existing Net::FTP::parse_response has a problem with some FTP sites.
(Well, not the sub itself, but how it works with the calling code.)
sub parse_response
{
return ($1, $2 eq "-")
if $_[1] =~ s/^(\d\d\d)(.?)//o;
my $ftp = shift;
# Darn MS FTP server is a load of CRAP !!!!
return ()
unless ${*$ftp}{'net_cmd_code'};
(${*$ftp}{'net_cmd_code'},1);
}
I ran into a site that, upon anonymous login, returns a blank
response (manually logging in got a 401 unauthorized error).
Assuming ${*$ftp}{'net_cmd_code'} is blank or 0, the sub above
will execute to the end, where it returns (0,1).
The problem is, the second value in the list is $more, which
tells the calling code to stay in its getline() loop. The
server isn't sending anything more, so getline() will execute
forever (and it really will, since something screws up any
alarm() calls you make around this code).
My solution was to put
return () unless ($_[1]);
in the sub. Now it works. For me, at least.
Hope this helps someone.
Adam
adamc@cnet.com