Browse files

adopt new socket usage

  • Loading branch information...
1 parent e480ffd commit 28161ebac8799a2dab22537c5f6dc39d35f54ef2 @moritz moritz committed Mar 17, 2011
Showing with 5 additions and 14 deletions.
  1. +3 −4 lib/LWP/Simple.pm
  2. +2 −10 t/socket-sanity.t
View
7 lib/LWP/Simple.pm
@@ -132,18 +132,17 @@ method decode_chunked (@content) {
return @content;
}
-method make_request ($hostname, $port, $path, %headers) {
+method make_request ($host, $port as Int, $path, %headers) {
my $headers = self.stringify_headers(%headers);
- my $sock = IO::Socket::INET.new;
- $sock.open($hostname, $port.Int, :bin);
+ my $sock = IO::Socket::INET.new(:$host, :$port);
my $req_str = "GET {$path} HTTP/1.1\r\n"
~ $headers
~ "\r\n";
$sock.send($req_str);
-
+;
my $resp = $sock.recv();
$sock.close();
View
12 t/socket-sanity.t
@@ -1,16 +1,8 @@
use v6;
use Test;
-plan 2;
+plan 1;
-my $s = IO::Socket::INET.new;
+my $s = IO::Socket::INET.new(:host('72.14.176.61'), :port(80));
ok($s, 'Socket object created');
-#my $opened = $s.open('www.rakudo.org', 80);
-my $opened = $s.open('72.14.176.61', 80);
-ok($opened, 'Socket to www.rakudo.org:80 opened');
-
-if ! $opened {
- diag("Failed opening the socket: $opened");
-}
-

0 comments on commit 28161eb

Please sign in to comment.