Subject: | Bad HTTP input crashes the server. |
Bad HTTP input causes the server to crash. The following error is printed:
Did not get DONE/CLOSE event for Wheel ID 3 from IP 127.0.0.1 at
/usr/local/lib/perl5/site_perl/5.8.7/POE/Component/Server/SimpleHTTP.pm
line 275.
Tried to send a response to the same connection twice! at
/usr/local/lib/perl5/site_perl/5.8.7/POE/Component/Server/SimpleHTTP.pm
line 857.
The test case server code is attached. To reproduce, send the following
(note how "GET" is spelled):
[dmitri@workstation ~]$ telnet localhost 8099
Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
GEt /hello.html HTTP/1.0
Connection closed by foreign host.
Subject: | simple-http-test.txt |
use POE qw(Component::Server::SimpleHTTP);
POE::Component::Server::SimpleHTTP->new(
'ALIAS' => 'SimpleHTTP',
'ADDRESS' => '0.0.0.0',
'PORT' => 8099,
'HANDLERS' => [
{
'DIR' => qr/^\/hello\.html$/,
'SESSION' => 'HTTPD',
'EVENT' => 'hello',
},
],
) or die 'Unable to create the HTTP Server';
POE::Session->create(
inline_states => {
'_start' => sub { $_[KERNEL]->alias_set('HTTPD') },
'hello' => \&handle_hello,
'not_found' => \&handle_not_found,
},
);
sub handle_hello {
my ( $request, $response, $dirmatch ) = @_[ ARG0 .. ARG2 ];
$response->code(200);
$response->content("Hello\n");
$_[KERNEL]->post('SimpleHTTP', 'DONE', $response );
}
$poe_kernel->run;