Sophie

Sophie

distrib > Mageia > 4 > x86_64 > by-pkgid > 449bc2c52128e77c3c0d58150afb6f4e > files > 114

perl-Plack-1.2.900-2.mga4.noarch.rpm

use AnyEvent;

my $app = sub {
    my $env = shift;

    warn "This app needs a server that supports psgi.streaming and psgi.nonblocking"
        unless $env->{'psgi.streaming'} && $env->{'psgi.nonblocking'};

    return sub {
        my $respond = shift;
        my $w = $respond->([ 200, ['Content-Type' => 'text/plain'] ]);
        $w->write("Hello\n");
        my $t; $t = AE::timer 2, 0, sub {
            undef $t;
            $w->write("World\n");
            $w->close;
        };
    };
};