App-cpantimes
view release on metacpan or search on metacpan
@_ == 2 || (@_ == 3 && ref $args eq 'HASH')
or Carp::croak(q/Usage: $http->get(URL, [HASHREF])/);
return $self->request('GET', $url, $args || {});
}
sub mirror {
my ($self, $url, $file, $args) = @_;
@_ == 3 || (@_ == 4 && ref $args eq 'HASH')
or Carp::croak(q/Usage: $http->mirror(URL, FILE, [HASHREF])/);
if ( -e $file and my $mtime = (stat($file))[9] ) {
$args->{headers}{'if-modified-since'} ||= $self->_http_date($mtime);
}
my $tempfile = $file . int(rand(2**31));
open my $fh, ">", $tempfile
or Carp::croak(qq/Error: Could not open temporary file $tempfile for downloading: $!/);
$args->{data_callback} = sub { print {$fh} $_[0] };
my $response = $self->request('GET', $url, $args);
close $fh
or Carp::croak(qq/Error: Could not close temporary file $tempfile: $!/);
if ( $response->{success} ) {
( run in 1.081 second using v1.01-cache-2.11-cpan-49f99fa48dc )