X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=src%2FNet.pl;h=035ceba84001833a50b4d58c36c0cb62fa9936ac;hb=d856cb02e0e8935a533fe09e8c958dcd9d819d95;hp=1d167cc04235ee661c6d24673cde934252b256c5;hpb=b7a8e5d306e1d80cb25312d5ddabe52616de821f;p=infobot.git diff --git a/src/Net.pl b/src/Net.pl index 1d167cc..035ceba 100644 --- a/src/Net.pl +++ b/src/Net.pl @@ -77,7 +77,7 @@ sub ftpGet { if (defined $lsize) { &DEBUG("FTP: locsize => '$lsize'."); if ($size != $lsize) { - &WARN("FTP: downloaded file seems truncated. FIXME."); + &FIXME("FTP: downloaded file seems truncated."); } } @@ -145,7 +145,7 @@ sub ftpList { ### LWP. # Usage: &getURL($url, [$post]); -# todo: rename this to getHTTP +# TODO: rename this to getHTTP sub getURL { my ($url,$post) = @_; my ($ua,$res,$req); @@ -181,20 +181,26 @@ sub getURL { sub getURLAsFile { my ($url,$file) = @_; my ($ua,$res,$req); + my $time = time(); + + unless (&loadPerlModule('LWP::UserAgent')) { + &::DEBUG('getURLAsFile: LWP::UserAgent not installed'); + return; + } - return unless &loadPerlModule("LWP::UserAgent"); $ua = new LWP::UserAgent; $ua->proxy('http', $param{'httpProxy'}) if &IsParam("httpProxy"); - my $req = HTTP::Request->new('GET', $url); - my $time = time(); + $req = HTTP::Request->new('GET', $url); &status("getURLAsFile: getting '$url' as '$file'"); - my $res = $ua->request($req, $file); + $res = $ua->request($req, $file); + my $delta_time = time() - $time; if ($delta_time) { my $size = -s $file || 0; my $rate = int($size / $delta_time / 1024); &status("getURLAsFile: Done. ($rate kB/sec)"); } + return $res; }