Amon2
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
t/600_plugins/012_streaming.t view on Meta::CPAN
use strict;
use warnings;
use utf8;
use Plack::Util;
use Plack::Test;
use Test::More;
use HTTP::Request::Common;
$Plack::Test::Impl = "Server";
use Amon2;
{
package MyApp::Web;
use parent -norequire, qw/MyApp/;
use parent qw/Amon2::Web/;
sub dispatch {
my $c = shift;
$c->streaming(sub {
my ($respond) = @_;
my $writer = $respond->(
[200, ['Content-Type', 'text/html']]);
$writer->write("<html>\n");
for my $i (1..5) {
$writer->write("<div>$i</div>\n");
}
$writer->write("</html>\n");
$writer->close;
});
}
}
{
package MyApp;
use parent qw/Amon2/;
__PACKAGE__->load_plugin('Amon2::Plugin::Web::Streaming');
}
my $app = MyApp::Web->to_app();
test_psgi $app, sub {
my $cb = shift;
my $res = $cb->(GET "/");
is $res->content, <<"...";
<html>
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
<div>5</div>
</html>
...
};
done_testing;
view all matches for this distributionview release on metacpan - search on metacpan
( run in 0.698 second using v1.00-cache-2.02-grep-82fe00e-cpan-2cc899e4a130 )