Permalink
Browse files

IO::Socket::INET.open() wants a Int port (thanks mstap)

  • Loading branch information...
1 parent f634ab9 commit f7a31dfa9cf72c9b17e6a3c4769c14e03f890d9b @cosimo cosimo committed Jul 31, 2010
Showing with 9 additions and 2 deletions.
  1. +4 −2 lib/LWP/Simple.pm
  2. +5 −0 t/parse-url.t
View
@@ -4,9 +4,9 @@
use v6;
use MIME::Base64;
-class LWP::Simple:auth<cosimo>:ver<0.05>;
+class LWP::Simple:auth<cosimo>:ver<0.06>;
-our $VERSION = '0.05';
+our $VERSION = '0.06';
method base64encode ($user, $pass) {
my $mime = MIME::Base64.new();
@@ -214,6 +214,8 @@ method parse_url (Str $url) {
# rakudo: Regex with captures doesn't work here
if $hostname ~~ /^ .+ \: \d+ $/ {
($hostname, $port) = $hostname.split(':');
+ # sock.open() fails if port is a Str
+ $port = $port.Int;
}
else {
$port = self.default_port($scheme);
View
@@ -37,5 +37,10 @@ for @test -> $test, $url, $results {
is($path, $results.[3], "Path for $url is $path");
}
+# Check that port is returned as a number,
+# or IO::Socket::INET.open() fails
+my ($scheme, $host, $port, $path) = LWP::Simple.parse_url('http://localhost:5984/foo/test/');
+is($port.WHAT, 'Int()', 'port is returned as a Int, to avoid problems on sock.open()');
+
done_testing;

0 comments on commit f7a31df

Please sign in to comment.