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);
use File::Temp;
use Getopt::Long qw(:config auto_help);
use List::MoreUtils qw(uniq);
use LWP::UserAgent;
use Mojo::UserAgent;
use Pod::Usage;
use AccountManager::DB;
......@@ -55,7 +55,9 @@ AccountManager::DB->register_db(
my $db = AccountManager::DB->new();
my $ua = LWP::UserAgent->new();
my $ua = Mojo::UserAgent->new(
max_redirect => 3
);
$db->begin_work();
......@@ -70,12 +72,15 @@ foreach my $id (keys %{$configuration->{federations}}) {
my $file = File::Temp->new();
my $url = $configuration->{federations}->{$id};
print "downloading metadata from url $url\n" if $options{verbose};
my $response = $ua->get($url, ':content_file' => $file->filename());
if (!$response->is_success()) {
my $result = $ua->get($url)->result();
if (!$result->is_success()) {
$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;
eval {
$metadata = AccountManager::Metadata->new(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment