Skip to content
Snippets Groups Projects
Commit d8b19d6f authored by Guillaume ROUSSE's avatar Guillaume ROUSSE
Browse files

switch to Mojo::UserAgent

parent 550a5b3c
No related branches found
No related tags found
No related merge requests found
...@@ -11,7 +11,7 @@ use English qw(-no_match_vars); ...@@ -11,7 +11,7 @@ use English qw(-no_match_vars);
use File::Temp; use File::Temp;
use Getopt::Long qw(:config auto_help); use Getopt::Long qw(:config auto_help);
use List::MoreUtils qw(uniq); use List::MoreUtils qw(uniq);
use LWP::UserAgent; use Mojo::UserAgent;
use Pod::Usage; use Pod::Usage;
use AccountManager::DB; use AccountManager::DB;
...@@ -55,7 +55,9 @@ AccountManager::DB->register_db( ...@@ -55,7 +55,9 @@ AccountManager::DB->register_db(
my $db = AccountManager::DB->new(); my $db = AccountManager::DB->new();
my $ua = LWP::UserAgent->new(); my $ua = Mojo::UserAgent->new(
max_redirect => 3
);
$db->begin_work(); $db->begin_work();
...@@ -70,12 +72,15 @@ foreach my $id (keys %{$configuration->{federations}}) { ...@@ -70,12 +72,15 @@ foreach my $id (keys %{$configuration->{federations}}) {
my $file = File::Temp->new(); my $file = File::Temp->new();
my $url = $configuration->{federations}->{$id}; my $url = $configuration->{federations}->{$id};
print "downloading metadata from url $url\n" if $options{verbose}; print "downloading metadata from url $url\n" if $options{verbose};
my $response = $ua->get($url, ':content_file' => $file->filename()); my $result = $ua->get($url)->result();
if (!$response->is_success()) {
if (!$result->is_success()) {
$db->rollback(); $db->rollback();
die "failed to download federation metadata: " . $response->status_line(); die "failed to download federation metadata: " . $result->status_line();
} }
$result->save_to($file->filename());
my $metadata; my $metadata;
eval { eval {
$metadata = AccountManager::Metadata->new( $metadata = AccountManager::Metadata->new(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment