Created
September 27, 2009 07:52
-
-
Save sharifulin/194659 to your computer and use it in GitHub Desktop.
Simple POE server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict; | |
use POE qw(Component::Server::SimpleHTTP XS::Queue::Array Loop::IO_Poll); | |
POE::Component::Server::SimpleHTTP->new(ALIAS => 'HTTPD', PORT => 8010, HANDLERS => [{ DIR => '/', SESSION => 'MANAGER', EVENT => 'req' }]); | |
POE::Session->create(inline_states => { | |
_start => sub { $_[KERNEL]->alias_set('MANAGER') }, | |
req => sub { | |
for ($_[ARG1]) { | |
$_->code(200); | |
$_->header('content-type', 'text/plain'); | |
$_->content($_[ARG0]->uri); | |
$_[KERNEL]->post('HTTPD' => 'DONE' => $_); | |
} | |
}, | |
}); | |
POE::Kernel->run; | |
__END__ | |
Requests per second: 469.65 [#/sec] (mean) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment