Skip to content

Instantly share code, notes, and snippets.

@leedo
Created December 3, 2009 20:22
Show Gist options
  • Save leedo/248473 to your computer and use it in GitHub Desktop.
Save leedo/248473 to your computer and use it in GitHub Desktop.
http_request(GET => $url,
want_body_handle => 1,
sub {
my ($handle, $headers) = @_;
$self->response->headers($headers);
$handle->on_eof(sub {
$self->finish;
$handle->destroy
});
$handle->on_read(sub {
my $data = delete $_[0]{rbuf};
try {
$self->write(decode_utf8($data));
$self->flush(0);
} catch {
$self->finish;
$handle->destroy;
};
});
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment