Skip Menu |

This queue is for tickets about the Net-HTTP CPAN distribution.

Report information
The Basics
Id: 75618
Status: resolved
Priority: 0/
Queue: Net-HTTP

People
Owner: Nobody in particular
Requestors: Nick_Lamkins [...] symantec.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: IPv6 Address URLs Broken
Date: Wed, 7 Mar 2012 16:36:45 -0800
To: "bug-Net-HTTP [...] rt.cpan.org" <bug-Net-HTTP [...] rt.cpan.org>
From: Nick Lamkins <Nick_Lamkins [...] symantec.com>
Net::HTTP doesn't appear to handle ipv6 addresses correctly. In http_configure of Net/HTTP/Methods.pm, the code will search for something that appears to be a port at the end of PeerAddr (or PeerHost). When using an ipv6 style address, this pattern may incorrectly match the last segment of an ipv6 address. sub http_configure { my($self, $cnf) = @_; die "Listen option not allowed" if $cnf->{Listen}; my $explict_host = (exists $cnf->{Host}); my $host = delete $cnf->{Host}; my $peer = $cnf->{PeerAddr} || $cnf->{PeerHost}; if (!$peer) { die "No Host option provided" unless $host; $cnf->{PeerAddr} = $peer = $host; } if ($peer =~ s,:(\d+)$,,) { # <-- BUG HERE - $peer could be an ipv6 address $cnf->{PeerPort} = int($1); # always override } <snip> Sample Code using LWP::UserAgent #!/usr/bin/env perl use Net::INET6Glue::INET_is_INET6; use LWP::UserAgent; my $url = 'http://[1234:1234:1234:5:abc:abcd:abc1:123]:80/foo/bar.pl?param=true'; my $user_agent = LWP::UserAgent->new; my $request = HTTP::Request->new(GET => $url); my $response = $user_agent->request($request); if ($response->is_success) { print "OK\n"; } else { die($response->status_line); } The error is shown as: 500 Can't connect to 1234:1234:1234:5:abc:abcd:abc1:123:80 (Connection refused) at ./bug.pl line 16. Setting EXTRA_SOCK_OPTS turns out to be an awful workaround. @LWP::Protocol::http::EXTRA_SOCK_OPTS = (PeerAddr => '1234:1234:1234:5:abc:abcd:abc1:123:80'); Nick Lamkins Sr. Software Engineer, Symantec Corporation www.symantec.com<http://www.symantec.com/> Show quoted text
________________________________ Office: (503) 614-5039 Fax: (503) 614-5060 nick_lamkins@symantec.com
________________________________ [cid:9CC5DD25-B7F1-488B-8109-2C9197866A89] This message (including any attachments) is intended only for the use of the individual or entity to which it is addressed and may contain information that is non-public, proprietary, privileged, confidential, and exempt from disclosure under applicable law or may constitute as attorney work product. If you are not the intended recipient, you are hereby notified that any use, dissemination, distribution, or copying of this communication is strictly prohibited. If you have received this communication in error, notify us immediately by telephone and (i) destroy this message if a facsimile or (ii) delete this message immediately if this is an electronic communication.
SYMCloud_RGB[2][3].png
From: maf [...] open.ch
I have the same problem. The workaround seems very clumsy. Is there any intention to fix this? Could this just be skipped for IPv6 addresses?
Subject: [rt.cpan.org #75618] IPv6 Address URLs Broken
Date: Wed, 10 Apr 2013 16:51:17 +0200 (CEST)
To: bug-Net-HTTP [...] rt.cpan.org
From: Milos Vyletel <milos.vyletel [...] sde.cz>
I've spent some time over past few days trying to figure out exactly same issue as is described here. I wish I've had find this bug report sooner. Anyway, I've reached the same conclusion as Nick. That code should be skipped for IPv6 or better regexp should be in place to correctly extract port from all addresses. What I've found to be easier workaround than setting EXTRA_SOCK_OPTS is to use double square brackets. I've used same example code above just added some debugging output to Net::HTTP::Methods my $url = 'http://[fc00::3]/'; $VAR1 = { 'Proto' => 'tcp', 'PeerAddr' => 'fc00::3', 'SendTE' => 1, 'PeerPort' => 3, # PeerPort incorrectly set to 3 'KeepAlive' => '' }; my $url = 'http://[[fc00::3]]/'; $VAR1 = { 'Proto' => 'tcp', 'PeerAddr' => '[fc00::3]', 'SendTE' => 1, 'PeerPort' => 80, # PeerPort is now correctly set to default 'KeepAlive' => '' };
From: jfesler [...] gigo.com
I humbly offer: https://github.com/libwww-perl/net-http/pull/10 https://github.com/libwww-perl/libwww-perl/pull/58 The combination will use IO::Socket::IP or IO::Socket::INET6 (if found); and uses URI to do host address parsing (in order to correctly parse [2001:db8::1]:80).
From: jfesler [...] gigo.com
My patches appear to be accepted, and a new release produced. Please consider updating to these packages: Net::HTTP (6.07) LWP (6.080 URI (1.64)