Skip to content

Commit

Permalink
do not support streaming interface, at least for now. Fixes a bug whe…
Browse files Browse the repository at this point in the history
…re Content-Length gets a wrong value when body does not have </html>
  • Loading branch information
miyagawa committed Dec 17, 2009
1 parent 7817433 commit f1b23b5
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions lib/Plack/Middleware/Debug.pm
Original file line number Diff line number Diff line change
Expand Up @@ -144,15 +144,18 @@ sub call {
panels => $self->panels,
BASE_URL => $env->{SCRIPT_NAME},
};
my $content = $self->renderer->($vars);
if (my $cl = $headers->get('Content-Length')) {
$headers->set('Content-Length' => $cl + length $content);
}
return sub {
my $chunk = shift;
return unless defined $chunk;
$chunk =~ s!(?=</body>)!$content!i;
return $chunk;

if ($res->[2]) {
my $content = $self->renderer->($vars);
my @body;
Plack::Util::foreach($res->[2], sub {
my $chunk = shift;
$chunk =~ s!(?=</body>)!$content!i;
push @body, $chunk;
});

$headers->set('Content-Length' => length(join '', @body));
$res->[2] = \@body;
};
}
$res;
Expand Down

0 comments on commit f1b23b5

Please sign in to comment.