Skip to content

Commit

Permalink
update to stop warning: use of Nil ...
Browse files Browse the repository at this point in the history
  • Loading branch information
Tony O'Dell committed Mar 23, 2017
1 parent 582038a commit de74dea
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
9 changes: 7 additions & 2 deletions lib/HTTP/Server/Async.pm6
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ class HTTP::Server::Async does HTTP::Server {
$req = Nil if $req !~~ Nil && $req.^can('complete') && $req.complete;
if $req ~~ Nil || !( $req.^can('headers') && $req.headers.keys.elems ) {
my @lines = Buf.new($data[0..$index]).decode.lines;
my ($m, $u, $v) = @lines.shift.match(/^(.+?)\s(.+)\s(HTTP\/.+)$/).list.map({ .Str });
return unless @lines[0].match(/^(.+?)\s(.+)\s(HTTP\/.+)$/);
my ($m, $u, $v) = (@lines.shift.match(/^(.+?)\s(.+)\s(HTTP\/.+)$/) // []).list.map({ .Str });
my %h;
my $last-key = '';
for @lines -> $line {
Expand Down Expand Up @@ -182,7 +183,11 @@ class HTTP::Server::Async does HTTP::Server {

$bytes = :16($data.subbuf(0,$i).decode);
last if $data.elems < $i + $bytes;
{ $req.complete = True; last; } if $bytes == 0;
if $bytes == 0 {
try $data .=subbuf(3);
$req.complete = True;
last;
}
$i+=2;
$req.data ~= $data.subbuf($i, $i+$bytes-3);
try $data .=subbuf($i+$bytes+2);
Expand Down
1 change: 0 additions & 1 deletion t/07_chunkedrequestecho.t
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ my $data;
while (my $str = $client.recv) {
$data ~= $str;
}
$data.perl.say;
$client.close;
ok $data ~~ / "\r\n\r\nWikipedia in\r\n\r\nchunks" /, 'Test for chunked data echo';
# vi:syntax=perl6

0 comments on commit de74dea

Please sign in to comment.