Sophie

Sophie

distrib > Mageia > 6 > x86_64 > media > core-updates > by-pkgid > 8952bf99e053a3f2fd32087e96266c63 > files > 108

perl-Plack-1.4.700-1.1.mga6.noarch.rpm

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

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

    return sub {
        my $respond = shift;
        my $w = $respond->([ 200, ['X-Foo' => 'bar', 'Content-Type' => 'text/plain'] ]);
        my $t; $t = AE::timer 0, 1, sub {
            $t;
            # TODO handle client disconnect (broken pipe) and poll_cb
            $w->write(time . "\n");
        };
    };
};