Acme-HTTP

 view release on metacpan or  search on metacpan

lib/Acme/HTTP.pm  view on Meta::CPAN

    bless { hdl => $hdl };
}

sub read_entity_body {
    my $self = shift;

    my $hdl = $self->{'hdl'};
    my $sel = IO::Select->new($hdl);

    unless ($sel->can_read($Acme::HTTP::TimeOut)) {
        $@ = 'Timeout ('.$Acme::HTTP::TimeOut.' sec)';
        return;
    }

    my $bytes = $hdl->read_entity_body($_[0], $_[1]);

    unless (defined $bytes) {
        $@ = "$!";
        return;
    }

lib/Acme/HTTP.pm  view on Meta::CPAN


    use Acme::HTTP;

    # you can use http:
    my $url = "http://perldoc.perl.org/perlfaq5.html";

    # ...or, alternatively, use https:
    #  $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') {

lib/Acme/HTTP.pm  view on Meta::CPAN

=head1 PARAMETERS

The following parameters can be set in advance:

=over

=item set_redir_max($count)

Set the maximum number of redirections

=item set_timeout($sec)

Set the timout in seconds

=back

=head1 RETURN VALUES

The following variables are available read-only after new():

=over

=item get_url_act()

lib/Acme/HTTP.pm  view on Meta::CPAN

...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'

  'Age'            => '0'
  'Set-Cookie'     => '...expires=12-Sep-2031...; secure',
  'Server'         => 'nginx/0.7.67',
  'Vary'           => 'Accept-Encoding,Cookie'
  'Via'            => '1.1 varnish',
  'X-Cache'        => 'MISS, MISS',
  'X-Cache-Hits'   => '0, 0',
  'X-Runtime'      => '0.479137'
  'X-Served-By'    => 'cache-lo80-LHR, cache-fra1222-FRA',

=head1 AUTHOR



( run in 1.029 second using v1.01-cache-2.11-cpan-39bf76dae61 )