line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package XML::RPC::UA::AnyEvent; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
73428
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
39
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
35
|
|
5
|
1
|
|
|
1
|
|
5
|
use HTTP::Response; |
|
1
|
|
|
|
|
20
|
|
|
1
|
|
|
|
|
21
|
|
6
|
1
|
|
|
1
|
|
5
|
use HTTP::Headers; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
28
|
|
7
|
1
|
|
|
1
|
|
6
|
use AnyEvent::HTTP 'http_request'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
91
|
|
8
|
1
|
|
|
1
|
|
6
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
55
|
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
5
|
use XML::RPC::Fast (); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
214
|
|
11
|
|
|
|
|
|
|
our $VERSION = $XML::RPC::Fast::VERSION; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 NAME |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
XML::RPC::UA::AnyEvent - XML::RPC useragent, using AnyEvent::HTTP |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 SYNOPSIS |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
use XML::RPC::Fast; |
20
|
|
|
|
|
|
|
use XML::RPC::UA::AnyEvent; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
my $rpc = XML::RPC::Fast->new( |
23
|
|
|
|
|
|
|
$uri, |
24
|
|
|
|
|
|
|
ua => XML::RPC::UA::AnyEvent->new( |
25
|
|
|
|
|
|
|
ua => 'YourApp/0.1', |
26
|
|
|
|
|
|
|
timeout => 3, |
27
|
|
|
|
|
|
|
), |
28
|
|
|
|
|
|
|
); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 DESCRIPTION |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
Asyncronous useragent for L. Could be used in any AnyEvent application. |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head1 IMPLEMENTED METHODS |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head2 new |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head2 async = 1 |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head2 call |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head1 SEE ALSO |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=over 4 |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=item * L |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
Base class (also contains documentation) |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=item * L |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
Syncronous UA using AnyEvent |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=item * L |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
DBI of event-loop programming |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=item * L |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
HTTP-client using AnyEvent |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=back |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=cut |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
67
|
0
|
|
|
0
|
1
|
|
sub async { 1 } |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub new { |
70
|
0
|
|
|
0
|
1
|
|
my $pkg = shift; |
71
|
0
|
|
|
|
|
|
my %args = @_; |
72
|
0
|
|
0
|
|
|
|
return bless \(do {my $o = $args{ua} || 'XML-RPC-Fast/'.$XML::RPC::Fast::VERSION }),$pkg; |
|
0
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub call { |
76
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
77
|
0
|
|
|
|
|
|
my ($method, $url) = splice @_,0,2; |
78
|
0
|
|
|
|
|
|
my %args = @_; |
79
|
0
|
0
|
|
|
|
|
$args{cb} or croak "cb required for useragent @{[%args]}"; |
|
0
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
#warn "call"; |
81
|
|
|
|
|
|
|
http_request |
82
|
|
|
|
|
|
|
$method => $url, |
83
|
|
|
|
|
|
|
headers => { |
84
|
|
|
|
|
|
|
'Content-Type' => 'text/xml', |
85
|
|
|
|
|
|
|
'User-Agent' => $$self, |
86
|
1
|
0
|
|
1
|
|
6
|
do { use bytes; ( 'Content-Length' => length($args{body}) ) }, |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
8
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
%{$args{headers} || {}}, |
88
|
|
|
|
|
|
|
}, |
89
|
|
|
|
|
|
|
body => $args{body}, |
90
|
|
|
|
|
|
|
cb => sub { |
91
|
0
|
|
|
|
|
|
$args{cb}( HTTP::Response->new( |
92
|
|
|
|
|
|
|
$_[1]{Status}, |
93
|
|
|
|
|
|
|
$_[1]{Reason}, |
94
|
0
|
|
|
0
|
|
|
HTTP::Headers->new(%{$_[1]}), |
95
|
|
|
|
|
|
|
$_[0], |
96
|
|
|
|
|
|
|
) ); |
97
|
|
|
|
|
|
|
}, |
98
|
0
|
|
|
|
|
|
; |
99
|
0
|
|
|
|
|
|
return; |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
1; |