Browse files

return sysread() rc value for get_chunk

  • Loading branch information...
1 parent b2f3532 commit 0f80c867f1a45dc645784456ced09ed2d81b139e @miyagawa committed Feb 9, 2010
Showing with 8 additions and 9 deletions.
  1. +8 −9 lib/Nomo/Server.pm
View
17 lib/Nomo/Server.pm
@@ -280,21 +280,21 @@ sub _prepare_env {
my $get_chunk = sub {
if ($self->{client}->{inputbuf}) {
- return delete $self->{client}->{inputbuf};
+ my $chunk = delete $self->{client}->{inputbuf};
+ return ($chunk, length $chunk);
}
- sysread STDIN, my($chunk), CHUNKSIZE;
- return $chunk;
+ my $read = sysread STDIN, my($chunk), CHUNKSIZE;
+ return ($chunk, $read);
};
my $chunked = do { no warnings; lc delete $env->{HTTP_TRANSFER_ENCODING} eq 'chunked' };
if (my $cl = $env->{CONTENT_LENGTH}) {
my $buf = Plack::TempBuffer->new($cl);
while ($cl > 0) {
- if (defined(my $chunk = $get_chunk->())) {
- $cl -= length $chunk;
- $buf->print($chunk);
- }
+ my($chunk, $read) = $get_chunk->();
+ $cl -= $read;
+ $buf->print($chunk);
}
$env->{'psgix.input.buffered'} = $env->{'psgi.input'} = $buf->rewind;
} elsif ($chunked) {
@@ -304,8 +304,7 @@ sub _prepare_env {
DECHUNK:
while (1) {
- my $chunk = $get_chunk->();
- my $read = length $chunk;
+ my($chunk, $read) = $get_chunk->();
$chunk_buffer .= $chunk;
while ( $chunk_buffer =~ s/^(([0-9a-fA-F]+).*\015\012)// ) {

0 comments on commit 0f80c86

Please sign in to comment.