Plack-Server-Coro
view release on metacpan or search on metacpan
Revision history for Perl extension Plack::Server::Coro
0.02 Sat Oct 24 01:27:12 PDT 2009
- Added psgi.streaming interface
0.01 Mon Oct 12 23:38:36 2009
- original version
lib/Plack/Server/Coro.pm view on Meta::CPAN
SCRIPT_NAME => '',
REMOTE_ADDR => $self->{server}{peeraddr},
'psgi.version' => [ 1, 0 ],
'psgi.errors' => *STDERR,
'psgi.input' => $self->{server}{client},
'psgi.url_scheme' => 'http', # SSL support?
'psgi.nonblocking' => Plack::Util::TRUE,
'psgi.run_once' => Plack::Util::FALSE,
'psgi.multithread' => Plack::Util::TRUE,
'psgi.multiprocess' => Plack::Util::FALSE,
'psgi.streaming' => Plack::Util::TRUE,
};
my $res = [ 400, [ 'Content-Type' => 'text/plain' ], [ 'Bad Request' ] ];
my $buf = '';
while (1) {
my $read = $fh->readline("\015\012\015\012")
or last;
$buf .= $read;
lib/Plack/Server/Coro.pm view on Meta::CPAN
$conn_value = $v;
}
}
unshift @lines, "HTTP/1.0 $res->[0] @{[ HTTP::Status::status_message($res->[0]) ]}\015\012";
push @lines, "\015\012";
$fh->syswrite(join '', @lines);
if (!defined $res->[2]) {
# streaming write
return Plack::Util::inline_object
write => sub { $fh->syswrite(join '', @_) },
close => $rouse_cb;
} elsif ($HasAIO && Plack::Util::is_real_fh($res->[2])) {
my $length = -s $res->[2];
my $offset = 0;
while (1) {
my $sent = aio_sendfile( $fh->fh, $res->[2], $offset, $length - $offset );
$offset += $sent if $sent > 0;
last if $offset >= $length;
( run in 0.562 second using v1.01-cache-2.11-cpan-4d50c553e7e )