line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WebService::Async::UserAgent::LWP; |
2
|
|
|
|
|
|
|
$WebService::Async::UserAgent::LWP::VERSION = '0.004'; |
3
|
1
|
|
|
1
|
|
94112
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
29
|
|
4
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
24
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
419
|
use parent qw(WebService::Async::UserAgent); |
|
1
|
|
|
|
|
225
|
|
|
1
|
|
|
|
|
4
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
WebService::Async::UserAgent::LWP - make requests using L |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 VERSION |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
version 0.004 |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 DESCRIPTION |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
Provides a L method which will use L to make |
19
|
|
|
|
|
|
|
requests and return a L containing the result. Used internally by |
20
|
|
|
|
|
|
|
L. |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=cut |
23
|
|
|
|
|
|
|
|
24
|
1
|
|
|
1
|
|
574
|
use Future; |
|
1
|
|
|
|
|
5793
|
|
|
1
|
|
|
|
|
26
|
|
25
|
1
|
|
|
1
|
|
5
|
use LWP::UserAgent; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
122
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head2 new |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
Instantiate. |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=cut |
32
|
|
|
|
|
|
|
|
33
|
1
|
|
|
1
|
1
|
11279
|
sub new { my $class = shift; bless {@_}, $class } |
|
1
|
|
|
|
|
4
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head2 request |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
Issues the request. Expects a single L object, |
38
|
|
|
|
|
|
|
and returns a L which will resolve to the decoded |
39
|
|
|
|
|
|
|
response content on success, or the failure reason on failure. |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=cut |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub request { |
44
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
45
|
0
|
|
|
|
|
|
my $req = shift; |
46
|
0
|
|
|
|
|
|
my $resp = $self->ua->request($req); |
47
|
0
|
0
|
|
|
|
|
return Future->new->done($resp->decoded_content) if $resp->is_success; |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
my $status = join ' ', $resp->code, $resp->message; |
50
|
0
|
|
|
|
|
|
return Future->new->fail($status, $resp, $req) |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head2 ua |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
Returns the L instance. |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=cut |
58
|
|
|
|
|
|
|
|
59
|
0
|
|
0
|
0
|
1
|
|
sub ua { shift->{ua} ||= LWP::UserAgent->new } |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
1; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 AUTHOR |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
Tom Molesworth |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 LICENSE |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Copyright Tom Molesworth 2012-2015. Licensed under the same terms as Perl itself. |