Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 39 lines (27 sloc) 0.654 kB
199cb74 @rcaputo Try to illustrate a more common way to call back.
authored
1 #!/usr/bin/env perl
2 # vim: ts=2 sw=2 noexpandtab
3
4 use warnings;
5 use strict;
6 use lib qw(../lib);
7
8 # HttpClient is a wrapper for POE::Component::Client::HTTP.
9 use HttpClient;
10
11 ### Main usage.
12
13 use HTTP::Request;
14
15 # 1. Create a user-agent object.
16
17 my $ua = HttpClient->new(
18 on_response => sub {
19 my ($self, $event) = @_;
20 print $event->response()->code(), " = ", $event->request->uri(), "\n";
21 },
22 );
23
24 # 2. Send a request.
25
26 $ua->request( HTTP::Request->new( GET => $_ ) ) foreach (
27 'http://poe.perl.org',
28 'http://duckduckgo.com/',
29 'http://metacpan.org/',
30 'http://perl.org/',
31 'http://twitter.com/',
32 );
33
34 # 3. Wait for stuff.
35
36 Reflex->run_all();
37
38 exit;
Something went wrong with that request. Please try again.