You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by af...@apache.org on 2012/10/17 11:01:08 UTC
svn commit: r1399155 -
/incubator/ooo/trunk/main/solenv/bin/download_external_dependencies.pl
Author: af
Date: Wed Oct 17 09:01:07 2012
New Revision: 1399155
URL: http://svn.apache.org/viewvc?rev=1399155&view=rev
Log:
Use LWP::Simple instead of LWP::UserAgent.
Modified:
incubator/ooo/trunk/main/solenv/bin/download_external_dependencies.pl
Modified: incubator/ooo/trunk/main/solenv/bin/download_external_dependencies.pl
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/solenv/bin/download_external_dependencies.pl?rev=1399155&r1=1399154&r2=1399155&view=diff
==============================================================================
--- incubator/ooo/trunk/main/solenv/bin/download_external_dependencies.pl (original)
+++ incubator/ooo/trunk/main/solenv/bin/download_external_dependencies.pl Wed Oct 17 09:01:07 2012
@@ -82,10 +82,18 @@ use strict;
use File::Spec;
use File::Path;
use File::Basename;
-use LWP::UserAgent;
use Digest::MD5;
use Digest::SHA;
use URI;
+my $simple = 1;
+if ($simple)
+{
+ use LWP::Simple;
+}
+else
+{
+ use LWP::UserAgent;
+}
my $Debug = 1;
@@ -529,38 +537,59 @@ sub DownloadFile ($$$)
}
# Download the extension.
- my $agent = LWP::UserAgent->new();
- $agent->timeout(120);
- $agent->env_proxy;
- $agent->show_progress(1);
- my $last_was_redirect = 0;
- $agent->add_handler('response_redirect'
- => sub{
- $last_was_redirect = 1;
- return;
- });
- $agent->add_handler('response_data'
- => sub{
- if ($last_was_redirect)
- {
- $last_was_redirect = 0;
- # Throw away the data we got so far.
- $digest->reset();
- close $out;
- open $out, ">$temporary_filename";
- binmode($out);
- }
- my($response,$agent,$h,$data)=@_;
- print $out $data;
- $digest->add($data);
- });
-
- my $response = $agent->get($URL);
- close $out;
+ my $success = 0;
+ if ($simple)
+ {
+ my $content = LWP::Simple::get($URL);
+ $success = defined $content;
+ if ($success)
+ {
+ open $out, ">$temporary_filename";
+ binmode($out);
+ print $out $content;
+ close($out);
+ $digest->add($content);
+ }
+ else
+ {
+ print "download from $URL failed\n";
+ }
+ }
+ else
+ {
+ my $agent = LWP::UserAgent->new();
+ $agent->timeout(120);
+ $agent->env_proxy;
+ $agent->show_progress(1);
+ my $last_was_redirect = 0;
+ $agent->add_handler('response_redirect'
+ => sub{
+ $last_was_redirect = 1;
+ return;
+ });
+ $agent->add_handler('response_data'
+ => sub{
+ if ($last_was_redirect)
+ {
+ $last_was_redirect = 0;
+ # Throw away the data we got so far.
+ $digest->reset();
+ close $out;
+ open $out, ">$temporary_filename";
+ binmode($out);
+ }
+ my($response,$agent,$h,$data)=@_;
+ print $out $data;
+ $digest->add($data);
+ });
+ $success = $agent->get($URL)->is_success();
+ close $out;
+ }
+
# When download was successfull then check the checksum and rename the .part file
# into the actual extension name.
- if ($response->is_success())
+ if ($success)
{
my $file_checksum = $digest->hexdigest();
if (defined $checksum)