Skip to content
Browse files

Better bad-request handling and correct http version detection

  • Loading branch information...
1 parent 0682b6c commit 3a632460c7a350358b3f275a4246bf9a0f72c529 @frodwith committed Oct 15, 2009
Showing with 12 additions and 5 deletions.
  1. +12 −5 lib/Plack/Server/POE.pm
View
17 lib/Plack/Server/POE.pm
@@ -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},
@@ -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')

0 comments on commit 3a63246

Please sign in to comment.
Something went wrong with that request. Please try again.