Skip to content

Commit

Permalink
Better bad-request handling and correct http version detection
Browse files Browse the repository at this point in the history
  • Loading branch information
frodwith committed Oct 16, 2009
1 parent 0682b6c commit 3a63246
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions lib/Plack/Server/POE.pm
Expand Up @@ -36,7 +36,14 @@ sub register_service {
my ($kernel, $heap, $req) = @_[KERNEL, HEAP, ARG0];
my $client = $heap->{client};

my $protocol = $req->protocol || 'HTTP/0.9';
unless ($req->isa('HTTP::Request')) {
$client->put($req->as_string);
$poe_kernel->yield('shutdown');
return;
}

my $version = $req->header('X-HTTP-Version') || '0.9';
my $protocol = "HTTP/$version";

my $env = req_to_psgi($req,
SERVER_NAME => $self->{host},
Expand All @@ -46,10 +53,10 @@ sub register_service {
'psgi.runonce' => Plack::Util::FALSE,
);

my $connection = $req->header('Connection');
my $v09 = $protocol eq 'HTTP/0.9';
my $v10 = $protocol eq 'HTTP/1.0';
my $v11 = $protocol eq 'HTTP/1.1';
my $connection = $req->header('Connection') || '';
my $v09 = $version eq '0.9';
my $v10 = $version eq '1.0';
my $v11 = $version eq '1.1';

my $keep_alive = !$v09 && (
($v10 && $connection eq 'Keep-Alive')
Expand Down

0 comments on commit 3a63246

Please sign in to comment.