Skip to content

Commit

Permalink
check if content-length header exists before destroying ->[1] (or kee…
Browse files Browse the repository at this point in the history
…p-alive won't work)
  • Loading branch information
kazuho committed Oct 1, 2009
1 parent b71452a commit 78fb4b1
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions lib/Plack/Server/Standalone.pm
Expand Up @@ -117,15 +117,14 @@ sub handle_connection {
"Date: @{[HTTP::Date::time2str()]}\015\012",
"Server: Plack-Server-Standalone/$Plack::VERSION\015\012",
);
my $has_cl = Plack::Util::header_exists($res->[1], 'Content-Length');
while (my ($k, $v) = splice(@{$res->[1]}, 0, 2)) {
push @lines, "$k: $v\r\n";
if (lc $k eq 'connection') {
$conn_value = $v;
}
}

my $has_cl = Plack::Util::header_exists($res->[1], 'Content-Length');

if ($req_count < $self->{max_keepalive_reqs} && $has_cl && ! defined($conn_value) && ($env->{HTTP_CONNECTION} || '') =~ /keep-alive/i) {
unshift @lines, "Connection: keep-alive\r\n";
$conn_value = "keep-alive";
Expand Down

0 comments on commit 78fb4b1

Please sign in to comment.