Return-Path: X-Original-To: apmail-incubator-ooo-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-ooo-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B1CBBD4BB for ; Wed, 17 Oct 2012 09:02:00 +0000 (UTC) Received: (qmail 97952 invoked by uid 500); 17 Oct 2012 09:01:59 -0000 Delivered-To: apmail-incubator-ooo-commits-archive@incubator.apache.org Received: (qmail 97755 invoked by uid 500); 17 Oct 2012 09:01:55 -0000 Mailing-List: contact ooo-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: ooo-dev@incubator.apache.org Delivered-To: mailing list ooo-commits@incubator.apache.org Received: (qmail 97694 invoked by uid 99); 17 Oct 2012 09:01:52 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 17 Oct 2012 09:01:52 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 17 Oct 2012 09:01:51 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 5105D238896F; Wed, 17 Oct 2012 09:01:08 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1399155 - /incubator/ooo/trunk/main/solenv/bin/download_external_dependencies.pl Date: Wed, 17 Oct 2012 09:01:08 -0000 To: ooo-commits@incubator.apache.org From: af@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20121017090108.5105D238896F@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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)