Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
use body method for streaming recipe
  • Loading branch information
kraih committed Nov 10, 2011
1 parent d280d02 commit 3c87812
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
3 changes: 3 additions & 0 deletions Changes
@@ -1,5 +1,8 @@
This file documents the revision history for Perl extension Mojolicious.

2.27 2011-11-11 00:00:00
- Improved documentation.

2.26 2011-11-10 00:00:00
- Added EXPERIMENTAL upgrade event to Mojo::Asset::Memory.
- Added EXPERIMENTAL upgrade event to Mojo::Transaction::HTTP.
Expand Down
3 changes: 2 additions & 1 deletion lib/Mojo/Content/Single.pm
Expand Up @@ -112,7 +112,8 @@ implements the following new ones.
my $asset = $single->asset;
$single = $single->asset(Mojo::Asset::Memory->new);
The actual content, defaults to a L<Mojo::Asset::Memory> object.
The actual content, defaults to a L<Mojo::Asset::Memory> object with
C<auto_upgrade> enabled.
=head2 C<auto_upgrade>
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojolicious.pm
Expand Up @@ -35,7 +35,7 @@ has static => sub { Mojolicious::Static->new };
has types => sub { Mojolicious::Types->new };

our $CODENAME = 'Leaf Fluttering In Wind';
our $VERSION = '2.26';
our $VERSION = '2.27';

# "These old doomsday devices are dangerously unstable.
# I'll rest easier not knowing where they are."
Expand Down
11 changes: 6 additions & 5 deletions lib/Mojolicious/Guides/Cookbook.pod
Expand Up @@ -457,14 +457,15 @@ L<Mojo::UserAgent> makes it actually easy.

my $ua = Mojo::UserAgent->new;
my $tx = $ua->build_tx(GET => 'http://mojolicio.us');
$tx->res->content->unsubscribe('read')->on(read => sub {
my ($content, $chunk) = @_;
say $chunk;
$tx->res->body(sub {
my ($res, $chunk) = @_;
say "Streaming: $chunk";
});
$ua->start($tx);

The C<read> event will be emitted for every chunk of data that is received,
even C<chunked> encoding will be handled transparently if necessary.
The C<body> method can be used to replace all C<read> events, which will be
emitted for every chunk of data that is received, even C<chunked> encoding
will be handled transparently if necessary.

=head2 Streaming request

Expand Down

0 comments on commit 3c87812

Please sign in to comment.