perl6 Socket: 发送HTTP请求

sub MAIN(Str $host,Str $path,  Int $port) {
  my $send = "GET $path HTTP/1.1\r\nHost: $host\r\n\r\n";
  my $c = IO::Socket::INET.new(:host($host), :port($port));
  $c.print: $send;
  while (my $buff = $c.recv(1024)) {
    say $buff.print;
  }
  $c.close;
}

 

posted on 2017-08-23 07:07  Perl6  阅读(253)  评论(0编辑  收藏  举报

导航