Acme-HTTP
view release on metacpan or search on metacpan
lib/Acme/HTTP.pm view on Meta::CPAN
# $url = "https://metacpan.org/pod/Data::Dumper";
set_redir_max(3); # Max. number of redirections
set_timeout(10); # Timeout in seconds
my $obj = Acme::HTTP->new($url) || die $@;
my $code = get_code();
my $msg = get_message();
if ($code eq '404') {
die "Page '$url' not found";
}
elsif ($code ne '200') {
die "Page '$url' - Error $code, Msg '$msg'";
}
print "Orig url = ", $url, "\n";
print "Real url = ", get_url_act(), "\n";
print "Redirections = ", get_redir_act(), "\n";
print "Length = ", get_response()->{'Content-Length'} // 0, "\n";
lib/Acme/HTTP.pm view on Meta::CPAN
=head2 List of values
In case of a successful new(), the subroutines get_code() and
get_message() are usually set as follows:
get_code() => '200'
get_message() => 'OK'
However, a non-existing address would typically return different values:
get_code() => '404'
get_message() => 'Not Found'
Here is one sample result of get_response() of an MP3 file:
'Content-Type' => 'audio/mpeg'
'Content-Length' => '28707232'
'Date' => 'Sun, 17 Aug 2014 10:53:43 GMT'
'Last-Modified' => 'Thu, 10 Jul 2014 04:52:52 GMT'
'Accept-Ranges' => 'bytes'
'Connection' => 'close'
'Cache-Control' => 'max-age=2269915'
'ETag' => '"1404967972"'
'X-HW' => '1408272823.dop...pa1.c'
...and here is another example result of get_esponse() of a web page:
'Content-Type' => 'text/html; charset=utf-8'
'Content-Length' => '31569'
'Date' => 'Sun, 17 Aug 2014 11:02:54 GMT'
'Last-Modified' => 'Thu, 24 Jul 2014 03:31:45 GMT'
'Accept-Ranges' => 'bytes'
'Connection' => 'close'
( run in 1.322 second using v1.01-cache-2.11-cpan-39bf76dae61 )