Skip to content

Commit

Permalink
adopt new socket usage
Browse files Browse the repository at this point in the history
  • Loading branch information
moritz committed Mar 17, 2011
1 parent e480ffd commit 28161eb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 14 deletions.
7 changes: 3 additions & 4 deletions lib/LWP/Simple.pm
Expand Up @@ -132,18 +132,17 @@ method decode_chunked (@content) {
return @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 $headers = self.stringify_headers(%headers);


my $sock = IO::Socket::INET.new; my $sock = IO::Socket::INET.new(:$host, :$port);
$sock.open($hostname, $port.Int, :bin);
my $req_str = "GET {$path} HTTP/1.1\r\n" my $req_str = "GET {$path} HTTP/1.1\r\n"
~ $headers ~ $headers
~ "\r\n"; ~ "\r\n";


$sock.send($req_str); $sock.send($req_str);

;
my $resp = $sock.recv(); my $resp = $sock.recv();
$sock.close(); $sock.close();


Expand Down
12 changes: 2 additions & 10 deletions t/socket-sanity.t
@@ -1,16 +1,8 @@
use v6; use v6;
use Test; 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'); 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.