From f528cf34b242df22fcb555677eb3a3c9c712fef6 Mon Sep 17 00:00:00 2001 From: Stefano Zacchiroli Date: Sat, 17 Feb 2001 21:03:06 +0000 Subject: [PATCH] helm_wget subroutine now use LWP module and doesn't use any more external wget program --- helm/http_getter/http_getter.pl.in | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/helm/http_getter/http_getter.pl.in b/helm/http_getter/http_getter.pl.in index 85ed00a55..22fad1a3e 100755 --- a/helm/http_getter/http_getter.pl.in +++ b/helm/http_getter/http_getter.pl.in @@ -409,9 +409,9 @@ sub download } } else { # download file from net print "Downloading the $str file\n"; # download file - $ua = LWP::UserAgent->new; - $request = HTTP::Request->new(GET => "$url"); - $response = $ua->request($request, \&callback); + my $ua = LWP::UserAgent->new; + my $request = HTTP::Request->new(GET => "$url"); + my $response = $ua->request($request, \&callback); # cache retrieved file to disk # TODO: inefficent, I haven't yet undestood how to deflate @@ -465,21 +465,18 @@ sub answer } sub helm_wget { -#ported from helm_wget executable, TODO: rewrite without wget. #retrieve a file from an url and write it to a temp dir -#used for retrieve resource indexe from servers +#used for retrieve resource index from servers + $cont = ""; my ($prefix, $URL) = @_; - if ($URL =~ /^file:\//) { - $URL =~ s/^file:\///; - my $command = "mkdir -p $prefix ; cp $URL $prefix"; - print "$command\n"; - system($command) == 0 - or die "\"$command\" error"; - } else { - my $command = "wget -c -P $prefix $URL"; - system($command) == 0 - or die "\"$command\" error"; - } + my $ua = LWP::UserAgent->new; + my $request = HTTP::Request->new(GET => "$URL"); + my $response = $ua->request($request, \&callback); + my ($filename) = reverse (split "/", $URL); # get filename part of the URL + open (TEMP, "> $prefix/$filename") + || die "Cannot open temporary file: $prefix/$filename\n"; + print TEMP $cont; + close TEMP; } sub update { @@ -509,7 +506,6 @@ sub mk_urls_of_uris { while ($server = pop @servers) { #cicle on servers in reverse order print "processing server: $server ...\n"; chomp $server; - $debugserver = "http://dalamar.krynn.it/helm"; # FOR DEBUG ONLY: REMOVE ME !! helm_wget($tmp_dir, $server."/".$indexname); #get index $idxfile = $tmp_dir."/".$indexname; open (INDEX, "< $idxfile") or -- 2.39.2