Skip to content

Instantly share code, notes, and snippets.

@mxey
Created February 27, 2010 22:39
Show Gist options
  • Select an option

  • Save mxey/317021 to your computer and use it in GitHub Desktop.

Select an option

Save mxey/317021 to your computer and use it in GitHub Desktop.
use common::sense;
use AnyEvent::HTTP;
use Coro::Channel;
use Data::Dumper;
my $q = Coro::Channel->new();
http_get('http://www.chaosdorf.de',
on_header => sub {
my($hdr) = @_;
$q->put($hdr);
return 1;
},
on_body => sub {
my($partial) = @_;
$q->put($partial);
return 1
},
sub {
$q->put(undef);
},
);
my $hdr = $q->get();
print Dumper($hdr);
while (my $chunk = $q->get()) {
print $chunk;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment