diff options
author | Andinus <andinus@nand.sh> | 2020-06-10 17:15:08 +0530 |
---|---|---|
committer | Andinus <andinus@nand.sh> | 2020-06-10 17:15:08 +0530 |
commit | 0ff1f3d221ad52608ccfeb0e470b196a23395823 (patch) | |
tree | 12eaa17198d5336bedf687135a8ccb5167582fec | |
parent | b4e3aa288325e8541caaa30b53c9e6ced25273a4 (diff) | |
download | ara-0ff1f3d221ad52608ccfeb0e470b196a23395823.tar.gz |
Switch to HTTP::Tiny, add to cpanfile
HTTP::Tiny has more options.
-rwxr-xr-x | ara.pl | 15 | ||||
-rw-r--r-- | cpanfile | 5 |
2 files changed, 14 insertions, 6 deletions
diff --git a/ara.pl b/ara.pl index 963720d..4f5170a 100755 --- a/ara.pl +++ b/ara.pl @@ -76,15 +76,20 @@ if ( -e $file ) { if ( not -e $file or $file_mtime < Time::Moment->now_utc->minus_minutes(8) or $get_latest ) { - require File::Fetch; + require HTTP::Tiny; # Fetch latest data from api. my $url = 'https://api.covid19india.org/data.json'; - my $ff = File::Fetch->new(uri => $url); - # Save the api response under /tmp. - $file = $ff->fetch( to => '/tmp' ) - or die $ff->error; + my $response = HTTP::Tiny + ->new( verify_SSL => 1 ) + ->mirror($url, $file); + + die "Failed to fetch latest data... +Reason: $response->{reason}\n +Content: $response->{content} +Status: $response->{status}\n" + unless $response->{success}; } # Slurp api response to $file_data. diff --git a/cpanfile b/cpanfile index a809e67..b1b21f6 100644 --- a/cpanfile +++ b/cpanfile @@ -1,6 +1,9 @@ requires 'Time::Moment', '0.44'; requires 'Path::Tiny', '0.114'; -requires 'File::Fetch', '0.56'; +requires 'HTTP::Tiny', '0.076'; requires 'JSON::MaybeXS', '1.004002'; requires 'Text::ASCIITable', '0.22'; requires 'Getopt::Long', '2.5'; + +requires 'IO::Socket::SSL', '1.42' + or 'Net::SSLeay', '1.49'; |