-
-
Save ugexe/c7a14c1e78b19c26ede328220fa225e6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://github.com/ugexe/Perl6-Net--HTTP/blob/master/lib/Net/HTTP/Utils.pm6#L15 | |
# BEFORE (randomly fails to receive the first byte when calling .recv) | |
method get(Bool :$bin where *.so, Bool :$chomp = True) { | |
my $buf = $.recv(1, :bin); | |
while (my $byte = $.recv(1, :bin)).DEFINITE { | |
$buf ~= $byte; | |
last if $buf.subbuf(*-$CRLF-BYTES) eq $CRLF; | |
} | |
$ = ?$chomp ?? $buf.subbuf(0, $buf.bytes - $CRLF-BYTES) !! $buf; | |
} | |
# AFTER (attempting to get the first byte until a valid one is received seems to fix most of it) | |
method get(Bool :$bin where *.so, Bool :$chomp = True) { | |
my $buf; | |
repeat { | |
my $byte = $.recv(1, :bin); | |
next unless $byte.?bytes; | |
$buf = $byte; | |
} until $buf.?bytes; | |
while (my $byte = $.recv(1, :bin)).DEFINITE { | |
$buf ~= $byte; | |
last if $buf.subbuf(*-$CRLF-BYTES) eq $CRLF; | |
} | |
$ = ?$chomp ?? $buf.subbuf(0, $buf.bytes - $CRLF-BYTES) !! $buf; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
perl6 ua-test.pl6 --fetcher="net-http" --url="http://fys.wtf" | |
WARNINGS for /home/nickl/perl6/zef/site#sources/C08AD410934D5C4693A1BDB65B5B3E318653D859 (Net::HTTP::Transport): | |
Useless use of $req in sink context (line 55) | |
Hash %fetchers-so-far = {:curl, :http-useragent, :libcurl, :lwp, :net-http, :pp6} | |
627514803926751480392675148039276514803926751480392675148039267514803926715480392671548039267154803926715840392671584039267158043926715840392671584039267158403926715840932671584093267158409236715840932671584093267158409326715840932761584093267158409326715840932671584093267518409326715840932675814093267518409326751840932675148093267518409326751840932675180493267518409326751840932675184903267518409326751849032675184093267518490326751840932675184903267518409326751840932675184039267518409326751840932675184092367518409326751840923675184093267 | |
Method 'has-phasers' not found for invocant of class 'Buf[uint8]' | |
in method get at /home/nickl/.rakudobrew/moar-blead-nom/install/share/perl6/site/sources/FD67A2E501739D38DCE9D892D40CB3892E242C4F (Net::HTTP::Utils) line 17 | |
in code at /home/nickl/.rakudobrew/moar-blead-nom/install/share/perl6/site/sources/FD67A2E501739D38DCE9D892D40CB3892E242C4F (Net::HTTP::Utils) line 32 | |
in method round-trip at /home/nickl/.rakudobrew/moar-blead-nom/install/share/perl6/site/sources/C08AD410934D5C4693A1BDB65B5B3E318653D859 (Net::HTTP::Transport) line 31 | |
in method round-trip at /home/nickl/.rakudobrew/moar-blead-nom/install/share/perl6/site/sources/EE7F0BF9F648D4BD8EED17B9D304DDBE9E5DE231 (Net::HTTP::GET) line 28 | |
in method CALL-ME at /home/nickl/.rakudobrew/moar-blead-nom/install/share/perl6/site/sources/EE7F0BF9F648D4BD8EED17B9D304DDBE9E5DE231 (Net::HTTP::GET) line 21 | |
in method CALL-ME at /home/nickl/.rakudobrew/moar-blead-nom/install/share/perl6/site/sources/EE7F0BF9F648D4BD8EED17B9D304DDBE9E5DE231 (Net::HTTP::GET) line 18 | |
in block at ua-test.pl6 line 67 | |
in block at ua-test.pl6 line 53 | |
184092367184093627184093627184093672184093627184093672184093672184093671284093671284093671824093671824093671842093671824093671824093671820493671824093671820493671824093671820493671820493671820943671820943671820934671820934671820936471820934671820934671820934761820934761820934761820934761820934761280934761820934761280934761280934761208934761280934761280934761289034761280394761280394761280349761280394761280394 | |
started: 1000 | |
arrived: 954 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment