use LWP to download changelog

This commit is contained in:
Dietmar Maurer 2013-06-18 10:30:30 +02:00
parent 446f92178d
commit f5ed75de51

View File

@ -4,7 +4,10 @@ use strict;
use warnings; use warnings;
use File::stat (); use File::stat ();
use LWP::UserAgent;
use PVE::Tools qw(extract_param); use PVE::Tools qw(extract_param);
use PVE::Cluster;
use PVE::SafeSyslog; use PVE::SafeSyslog;
use PVE::INotify; use PVE::INotify;
use PVE::Exception qw(raise_param_exc); use PVE::Exception qw(raise_param_exc);
@ -343,10 +346,27 @@ __PACKAGE__->register_method({
my $data = ""; my $data = "";
# fixme: proxy? my $dccfg = PVE::Cluster::cfs_read_file('datacenter.cfg');
my $proxy = $dccfg->{http_proxy};
my $cmd = ['wget', '-T', 10, '-O-', $url]; my $ua = LWP::UserAgent->new;
PVE::Tools::run_command($cmd, outfunc => sub { $data .= shift . "\n"; }); $ua->agent("PVE/1.0");
$ua->timeout(10);
$ua->max_size(1024*1024);
if ($proxy) {
$ua->proxy(['http'], $proxy);
} else {
$ua->env_proxy;
}
my $response = $ua->get($url);
if ($response->is_success) {
$data = $response->decoded_content;
} else {
die $response->status_line;
}
return $data; return $data;
}}); }});