]> git.donarmstrong.com Git - infobot.git/blobdiff - src/Net.pl
* Removed old reference to chanServ_ops in docs
[infobot.git] / src / Net.pl
index c08341cd0e0f5a731f955c4b4fc813305d538312..e1f091087ee8292c8f8d56b24188daad7e737a02 100644 (file)
@@ -84,10 +84,10 @@ sub ftpGet {
     my $delta_time     = &timedelta($start_time);
     if ($delta_time > 0 and $verbose_ftp) {
        &status(sprintf("FTP: %.02f sec to complete.", $delta_time));
-       my ($rateunit,$rate) = ("B", $size / $delta_time);
+       my ($rateunit,$rate) = ('B', $size / $delta_time);
        if ($rate > 1024) {
            $rate /= 1024;
-           $rateunit = "kB";
+           $rateunit = 'kB';
        }
        &status(sprintf("FTP: %.01f ${rateunit}/sec.", $rate));
     }
@@ -153,7 +153,7 @@ sub getURL {
     return unless &loadPerlModule("LWP::UserAgent");
 
     $ua = new LWP::UserAgent;
-    $ua->proxy('http', $param{'httpProxy'}) if &IsParam("httpProxy");
+    $ua->proxy('http', $param{'httpProxy'}) if &IsParam('httpProxy');
 
     if (defined $post) {
        $req = new HTTP::Request('POST',$url);
@@ -183,10 +183,13 @@ sub getURLAsFile {
     my ($ua,$res,$req);
     my $time = time();
 
-    return unless &loadPerlModule("LWP::UserAgent");
+    unless (&loadPerlModule('LWP::UserAgent')) {
+       &::DEBUG('getURLAsFile: LWP::UserAgent not installed');
+       return;
+    }
 
     $ua = new LWP::UserAgent;
-    $ua->proxy('http', $param{'httpProxy'}) if &IsParam("httpProxy");
+    $ua->proxy('http', $param{'httpProxy'}) if &IsParam('httpProxy');
     $req = HTTP::Request->new('GET', $url);
     &status("getURLAsFile: getting '$url' as '$file'");
     $res = $ua->request($req, $file);
@@ -202,3 +205,5 @@ sub getURLAsFile {
 }
 
 1;
+
+# vim:ts=4:sw=4:expandtab:tw=80