Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

expect .recv( bin => True ) to return Buf

  • Loading branch information...
commit a793f13e97a9374d6c3e8bdaa14655e34ad5ee48 1 parent 8e9c8d3
@FROGGS FROGGS authored
Showing with 7 additions and 7 deletions.
  1. +5 −4 S32-io/IO-Socket-INET.pl
  2. +2 −3 S32-io/IO-Socket-INET.t
View
9 S32-io/IO-Socket-INET.pl
@@ -216,12 +216,13 @@
until $server_ready_flag_fn.IO ~~ :e { sleep(0.1) }
unlink $server_ready_flag_fn;
my $sock = IO::Socket::INET.new(:$host, :$port);
- my Str $recv;
- my Str $chunk;
- while $chunk = $sock.recv( 4096 ) {
+ my Buf $recv = Buf.new;
+ my Buf $chunk;
+ # in binary mode it will return a Buf, not Str
+ while $chunk = $sock.recv( 4096, bin => True ) {
$recv ~= $chunk;
}
- say $binary.decode('binary') eq $recv ?? 'OK-8' !! 'NOK-8';
+ say $binary eqv $recv ?? 'OK-8' !! 'NOK-8';
$sock.close();
}
}
View
5 S32-io/IO-Socket-INET.t
@@ -127,7 +127,7 @@ if $*OS eq any <linux darwin solaris MSWin32> { # please add more valid OS names
is $expected[$i++], '3', 'received last character';
is $expected[$i++], 4096 * 4, 'total amount ';
- # test 7 tests rcv with binary data
+ # test 7 tests recv with binary data
if $is-win {
$received = qqx{t\\spec\\S32-io\\IO-Socket-INET.bat 7 $port};
} else {
@@ -136,8 +136,7 @@ if $*OS eq any <linux darwin solaris MSWin32> { # please add more valid OS names
$expected = $received.split("\n");
is $expected[0], 'OK-7', 'successful read binary data';
- # test 8 tests recv with binary data. This test should show that
- # .recv will fall back to binary when utf-8 decoding fails.
+ # test 8 tests recv with binary data.
if $is-win {
$received = qqx{t\\spec\\S32-io\\IO-Socket-INET.bat 8 $port};
} else {
Please sign in to comment.
Something went wrong with that request. Please try again.