@@ -1,3 +1,9 @@
+2014-07-23 Net-HTTP 6.07
+
+Jason Fesler (1):
+ Opportunistically use IO::Socket::IP or IO::Socket::INET6.
+ Properly parse IPv6 literal addreses with optional port numbers. [RT#75618]
+
_______________________________________________________________________________
2013-03-10 Net-HTTP 6.06
@@ -10,4 +10,5 @@ t/http.t
t/http-nb.t
t/apache.t
t/apache-https.t
-META.yml Module meta-data (added by MakeMaker)
+META.yml Module YAML meta-data (added by MakeMaker)
+META.json Module JSON meta-data (added by MakeMaker)
@@ -0,0 +1,55 @@
+{
+ "abstract" : "Low-level HTTP connection (client)",
+ "author" : [
+ "Gisle Aas <gisle@activestate.com>"
+ ],
+ "dynamic_config" : 1,
+ "generated_by" : "ExtUtils::MakeMaker version 6.98, CPAN::Meta::Converter version 2.141170",
+ "license" : [
+ "perl_5"
+ ],
+ "meta-spec" : {
+ "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",
+ "version" : "2"
+ },
+ "name" : "Net-HTTP",
+ "no_index" : {
+ "directory" : [
+ "t",
+ "inc"
+ ]
+ },
+ "prereqs" : {
+ "build" : {
+ "requires" : {
+ "ExtUtils::MakeMaker" : "0"
+ }
+ },
+ "configure" : {
+ "requires" : {
+ "ExtUtils::MakeMaker" : "0"
+ }
+ },
+ "runtime" : {
+ "recommends" : {
+ "IO::Socket::SSL" : "1.38"
+ },
+ "requires" : {
+ "Compress::Raw::Zlib" : "0",
+ "IO::Compress::Gzip" : "0",
+ "IO::Select" : "0",
+ "IO::Socket::INET" : "0",
+ "URI" : "0",
+ "perl" : "5.006002"
+ }
+ }
+ },
+ "release_status" : "stable",
+ "resources" : {
+ "repository" : {
+ "url" : "http://github.com/libwww-perl/net-http"
+ },
+ "x_MailingList" : "mailto:libwww@perl.org"
+ },
+ "version" : "6.07"
+}
@@ -1,31 +1,32 @@
---- #YAML:1.0
-name: Net-HTTP
-version: 6.06
-abstract: Low-level HTTP connection (client)
+---
+abstract: 'Low-level HTTP connection (client)'
author:
- - Gisle Aas <gisle@activestate.com>
-license: perl
-distribution_type: module
-configure_requires:
- ExtUtils::MakeMaker: 0
+ - 'Gisle Aas <gisle@activestate.com>'
build_requires:
- ExtUtils::MakeMaker: 0
-requires:
- Compress::Raw::Zlib: 0
- IO::Compress::Gzip: 0
- IO::Select: 0
- IO::Socket::INET: 0
- perl: 5.006002
-resources:
- MailingList: mailto:libwww@perl.org
- repository: http://github.com/gisle/net-http
-no_index:
- directory:
- - t
- - inc
-generated_by: ExtUtils::MakeMaker version 6.57_05
+ ExtUtils::MakeMaker: '0'
+configure_requires:
+ ExtUtils::MakeMaker: '0'
+dynamic_config: 1
+generated_by: 'ExtUtils::MakeMaker version 6.98, CPAN::Meta::Converter version 2.141170'
+license: perl
meta-spec:
- url: http://module-build.sourceforge.net/META-spec-v1.4.html
- version: 1.4
+ url: http://module-build.sourceforge.net/META-spec-v1.4.html
+ version: '1.4'
+name: Net-HTTP
+no_index:
+ directory:
+ - t
+ - inc
recommends:
- IO::Socket::SSL: 1.38
+ IO::Socket::SSL: '1.38'
+requires:
+ Compress::Raw::Zlib: '0'
+ IO::Compress::Gzip: '0'
+ IO::Select: '0'
+ IO::Socket::INET: '0'
+ URI: '0'
+ perl: '5.006002'
+resources:
+ MailingList: mailto:libwww@perl.org
+ repository: http://github.com/libwww-perl/net-http
+version: '6.07'
@@ -26,13 +26,14 @@ WriteMakefile(
'IO::Select' => 0,
'Compress::Raw::Zlib' => 0,
'IO::Compress::Gzip' => 0,
+ 'URI' => 0,
},
META_MERGE => {
recommends => {
'IO::Socket::SSL' => "1.38",
},
resources => {
- repository => 'http://github.com/gisle/net-http',
+ repository => 'http://github.com/libwww-perl/net-http',
MailingList => 'mailto:libwww@perl.org',
}
},
@@ -4,8 +4,9 @@ require 5.005; # 4-arg substr
use strict;
use vars qw($VERSION);
+use URI;
-$VERSION = "6.06";
+$VERSION = "6.07";
my $CRLF = "\015\012"; # "\r\n" is not portable
@@ -44,20 +45,30 @@ sub http_configure {
$cnf->{PeerAddr} = $peer = $host;
}
- if ($peer =~ s,:(\d+)$,,) {
- $cnf->{PeerPort} = int($1); # always override
- }
- if (!$cnf->{PeerPort}) {
- $cnf->{PeerPort} = $self->http_default_port;
- }
-
- if (!$explict_host) {
- $host = $peer;
- $host =~ s/:.*//;
- }
- if ($host && $host !~ /:/) {
- my $p = $cnf->{PeerPort};
- $host .= ":$p" if $p != $self->http_default_port;
+ # CONNECTIONS
+ # PREFER: port number from PeerAddr, then PeerPort, then http_default_port
+ my $peer_uri = URI->new("http://$peer");
+ $cnf->{"PeerPort"} = $peer_uri->_port || $cnf->{PeerPort} || $self->http_default_port;
+ $cnf->{"PeerAddr"} = $peer_uri->host;
+
+ # HOST header:
+ # If specified but blank, ignore.
+ # If specified with a value, add the port number
+ # If not specified, set to PeerAddr and port number
+ # ALWAYS: If IPv6 address, use [brackets] (thanks to the URI package)
+ # ALWAYS: omit port number if http_default_port
+ if (($host) || (! $explict_host)) {
+ my $uri = ($explict_host) ? URI->new("http://$host") : $peer_uri->clone;
+ if (!$uri->_port) {
+ # Always use *our* $self->http_default_port instead of URI's (Covers HTTP, HTTPS)
+ $uri->port( $cnf->{PeerPort} || $self->http_default_port);
+ }
+ my $host_port = $uri->host_port; # Returns host:port or [ipv6]:port
+ my $remove = ":" . $self->http_default_port; # we want to remove the default port number
+ if (substr($host_port,0-length($remove)) eq $remove) {
+ substr($host_port,0-length($remove)) = "";
+ }
+ $host = $host_port;
}
$cnf->{Proto} = 'tcp';
@@ -3,10 +3,19 @@ package Net::HTTP;
use strict;
use vars qw($VERSION @ISA $SOCKET_CLASS);
-$VERSION = "6.06";
+$VERSION = "6.07";
unless ($SOCKET_CLASS) {
- eval { require IO::Socket::INET } || require IO::Socket;
- $SOCKET_CLASS = "IO::Socket::INET";
+ # Try several, in order of capability and preference
+ if (eval { require IO::Socket::IP }) {
+ $SOCKET_CLASS = "IO::Socket::IP"; # IPv4+IPv6
+ } elsif (eval { require IO::Socket::INET6 }) {
+ $SOCKET_CLASS = "IO::Socket::INET6"; # IPv4+IPv6
+ } elsif (eval { require IO::Socket::INET }) {
+ $SOCKET_CLASS = "IO::Socket::INET"; # IPv4 only
+ } else {
+ require IO::Socket;
+ $SOCKET_CLASS = "IO::Socket::INET";
+ }
}
require Net::HTTP::Methods;
require Carp;
@@ -59,10 +68,11 @@ C<Net::HTTP> class represents a connection to an HTTP server. The
HTTP protocol is described in RFC 2616. The C<Net::HTTP> class
supports C<HTTP/1.0> and C<HTTP/1.1>.
-C<Net::HTTP> is a sub-class of C<IO::Socket::INET>. 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.
+C<Net::HTTP> is a sub-class of one of C<IO::Socket::IP> (IPv6+IPv4),
+C<IO::Socket::INET6> (IPv6+IPv4), or C<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
C<IO::Socket::INET>):
@@ -84,6 +94,9 @@ C<IO::Socket::INET>'s as well as these:
The C<Host> option is also the default for C<IO::Socket::INET>'s
C<PeerAddr>. The C<PeerPort> defaults to 80 if not provided.
+The C<PeerPort> specification can also be embedded in the C<PeerAddr>
+by preceding it with a ":", and closing the IPv6 address on bracktes "[]" if
+necessary: "192.0.2.1:80","[2001:db8::1]:80","any.example.com:80".
The C<Listen> option provided by C<IO::Socket::INET>'s constructor
method is not allowed.