The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Net::HTTP - Low-level HTTP connection (client)

VERSION

version 6.17

SYNOPSIS

use Net::HTTP;
my $s = Net::HTTP->new(Host => "www.perl.com") || die $@;
$s->write_request(GET => "/", 'User-Agent' => "Mozilla/5.0");
my($code, $mess, %h) = $s->read_response_headers;

while (1) {
   my $buf;
   my $n = $s->read_entity_body($buf, 1024);
   die "read failed: $!" unless defined $n;
   last unless $n;
   print $buf;
}

DESCRIPTION

The Net::HTTP class is a low-level HTTP client. An instance of the Net::HTTP class represents a connection to an HTTP server. The HTTP protocol is described in RFC 2616. The Net::HTTP class supports HTTP/1.0 and HTTP/1.1.

Net::HTTP is a sub-class of one of IO::Socket::IP (IPv6+IPv4), IO::Socket::INET6 (IPv6+IPv4), or IO::Socket::INET (IPv4 only).
You can mix the methods described below with reading and writing from the socket directly. This is not necessary a good idea, unless you know what you are doing.

The following methods are provided (in addition to those of IO::Socket::INET):

SUBCLASSING

The read_response_headers() and read_entity_body() will invoke the sysread() method when they need more data. Subclasses might want to override this method to control how reading takes place.

The object itself is a glob. Subclasses should avoid using hash key names prefixed with http_ and io_.

SEE ALSO

LWP, IO::Socket::INET, Net::HTTP::NB

AUTHOR

Gisle Aas gisle@activestate.com

COPYRIGHT AND LICENSE

This software is copyright (c) 2001-2017 by Gisle Aas.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.