| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package XML::RPC::UA::LWP; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
1361
|
use strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
32
|
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
35
|
|
|
5
|
1
|
|
|
1
|
|
4
|
use base 'XML::RPC::UA'; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
69
|
|
|
6
|
1
|
|
|
1
|
|
789
|
use HTTP::Request; |
|
|
1
|
|
|
|
|
67055
|
|
|
|
1
|
|
|
|
|
43
|
|
|
7
|
1
|
|
|
1
|
|
42601
|
use LWP::UserAgent; |
|
|
1
|
|
|
|
|
149901
|
|
|
|
1
|
|
|
|
|
39
|
|
|
8
|
1
|
|
|
1
|
|
13
|
use Carp; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
85
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
6
|
use XML::RPC::Fast (); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
551
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = $XML::RPC::Fast::VERSION; |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 NAME |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
XML::RPC::UA::LWP - XML::RPC useragent, using LWP |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
use XML::RPC::Fast; |
|
20
|
|
|
|
|
|
|
use XML::RPC::UA::LWP; |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
my $rpc = XML::RPC::Fast->new( |
|
23
|
|
|
|
|
|
|
$uri, |
|
24
|
|
|
|
|
|
|
ua => XML::RPC::UA::LWP->new( |
|
25
|
|
|
|
|
|
|
ua => 'YourApp/0.1', |
|
26
|
|
|
|
|
|
|
timeout => 3, |
|
27
|
|
|
|
|
|
|
), |
|
28
|
|
|
|
|
|
|
); |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
Default syncronous useragent for L |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head1 IMPLEMENTED METHODS |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head2 new |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head2 async = 0 |
|
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
|
|
|
|
|
|
|
=back |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=cut |
|
55
|
|
|
|
|
|
|
|
|
56
|
0
|
|
|
0
|
1
|
|
sub async { 0 } |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub new { |
|
59
|
0
|
|
|
0
|
1
|
|
my $pkg = shift; |
|
60
|
0
|
|
|
|
|
|
my %args = @_; |
|
61
|
0
|
|
0
|
|
|
|
my $useragent = delete $args{ua} || 'XML-RPC-Fast/'.$XML::RPC::Fast::VERSION; |
|
62
|
0
|
|
|
|
|
|
my $ua = LWP::UserAgent->new( |
|
63
|
|
|
|
|
|
|
requests_redirectable => ['POST'], |
|
64
|
|
|
|
|
|
|
%args, |
|
65
|
|
|
|
|
|
|
); |
|
66
|
0
|
0
|
|
|
|
|
$ua->timeout( exists $args{timeout} ? $args{timeout} : 10 ); |
|
67
|
0
|
|
|
|
|
|
$ua->env_proxy(); |
|
68
|
0
|
|
|
|
|
|
return bless { |
|
69
|
|
|
|
|
|
|
lwp => $ua, |
|
70
|
|
|
|
|
|
|
ua => $useragent, |
|
71
|
|
|
|
|
|
|
}, $pkg; |
|
72
|
|
|
|
|
|
|
} |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub call { |
|
75
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
76
|
0
|
|
|
|
|
|
my ($method, $url) = splice @_,0,2; |
|
77
|
0
|
|
|
|
|
|
my %args = @_; |
|
78
|
0
|
0
|
|
|
|
|
$args{cb} or croak "cb required for useragent @{[%args]}"; |
|
|
0
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
#warn "call"; |
|
80
|
0
|
|
|
|
|
|
my $req = HTTP::Request->new( $method => $url ); |
|
81
|
0
|
|
|
|
|
|
$req->header('Content-Type' => 'text/xml'); |
|
82
|
0
|
|
|
|
|
|
$req->header('User-Agent' => $self->{ua}); |
|
83
|
0
|
|
|
|
|
|
$req->header( $_ => $args{headers}{$_} ) for keys %{$args{headers}}; |
|
|
0
|
|
|
|
|
|
|
|
84
|
0
|
0
|
|
|
|
|
if( utf8::is_utf8($args{body}) ) { |
|
85
|
0
|
|
|
|
|
|
carp "got an utf8 body: $args{body}"; |
|
86
|
0
|
|
|
|
|
|
utf8::encode($args{body}); |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
{ |
|
89
|
1
|
|
|
1
|
|
1392
|
use bytes; |
|
|
1
|
|
|
|
|
13
|
|
|
|
1
|
|
|
|
|
10
|
|
|
|
0
|
|
|
|
|
|
|
|
90
|
0
|
|
|
|
|
|
$req->header( 'Content-Length' => length($args{body}) ); |
|
91
|
|
|
|
|
|
|
} |
|
92
|
0
|
|
|
|
|
|
$req->content($args{body}); |
|
93
|
0
|
|
|
|
|
|
my $res = $self->{lwp}->request($req); |
|
94
|
|
|
|
|
|
|
#warn sprintf "http call lasts %0.3fs",time - $start if DEBUG_TIMES; |
|
95
|
0
|
|
|
|
|
|
$args{cb}( $res ); |
|
96
|
|
|
|
|
|
|
} |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
Copyright (c) 2008-2009 Mons Anderson. |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
|
103
|
|
|
|
|
|
|
under the same terms as Perl itself. |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 AUTHOR |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
Mons Anderson, C<< >> |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=cut |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
1; |