Skip to content

Commit

Permalink
fixed content test
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Jan 16, 2013
1 parent 2acdad7 commit 7cc950a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
1 change: 1 addition & 0 deletions Changes
Expand Up @@ -3,6 +3,7 @@
- Added modules Mojo::Server::Prefork and Mojolicious::Command::prefork.
- Updated jQuery to version 1.9.
- Improved documentation.
- Improved tests.
- Fixed small memory leak in Hypnotoad that only shows when Perl is compiled
with -DPERL_USE_SAFE_PUTENV. (lewoberst)

Expand Down
4 changes: 2 additions & 2 deletions lib/Mojo/Content.pm
Expand Up @@ -140,8 +140,8 @@ sub parse {
my $len = $headers->content_length || 0;
$self->{size} ||= 0;
if ((my $need = $len - $self->{size}) > 0) {
$need = length($self->{buffer}) if $need > length($self->{buffer});
my $chunk = substr $self->{buffer}, 0, $need, '';
my $len = length $self->{buffer};
my $chunk = substr $self->{buffer}, 0, $need > $len ? $len : $need, '';
$self->_uncompress($chunk);
$self->{size} += length $chunk;
}
Expand Down
10 changes: 5 additions & 5 deletions t/mojo/content.t
Expand Up @@ -77,12 +77,12 @@ ok !$content->charset, 'no charset';
'a' =~ /(.)/;
ok !$content->boundary, 'no boundary';

# Upload > 2G on 32-bit Perl
# Partial upload with 64bit content length
$content = Mojo::Content::Single->new;
$content->parse("Content-Length: 2200000000\r\n\r\nHello World!");
is $content->asset->size, 12, 'right upload size';
$content->parse("Content-Length: 2222222222\x0d\x0a\x0d\x0aHello World!");
is $content->asset->size, 12, 'right size';
$content = Mojo::Content::Single->new;
$content->parse("Content-Length: 4400000000\r\n\r\nHello World!");
is $content->asset->size, 12, 'right upload size';
$content->parse("Content-Length: 4444444444\x0d\x0a\x0d\x0aHello World!");
is $content->asset->size, 12, 'right size';

done_testing();

0 comments on commit 7cc950a

Please sign in to comment.