line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WWW::ORCID::Transport::LWP; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
80012
|
use strict; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
45
|
|
4
|
1
|
|
|
1
|
|
8
|
use warnings; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
59
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = 0.0401; |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
824
|
use LWP::UserAgent (); |
|
1
|
|
|
|
|
76502
|
|
|
1
|
|
|
|
|
42
|
|
9
|
1
|
|
|
1
|
|
626
|
use Moo; |
|
1
|
|
|
|
|
15225
|
|
|
1
|
|
|
|
|
9
|
|
10
|
1
|
|
|
1
|
|
2465
|
use namespace::clean; |
|
1
|
|
|
|
|
12571
|
|
|
1
|
|
|
|
|
10
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
with 'WWW::ORCID::Transport'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has _client => |
15
|
|
|
|
|
|
|
(is => 'ro', init_arg => 0, lazy => 1, builder => '_build_client',); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub _build_client { |
18
|
0
|
|
|
0
|
|
|
LWP::UserAgent->new; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub get { |
22
|
|
|
|
|
|
|
my ($self, $url, $params, $headers) = @_; |
23
|
|
|
|
|
|
|
$url = $self->_param_url($url, $params) if $params; |
24
|
|
|
|
|
|
|
my $res = $self->_client->get($url, %$headers); |
25
|
|
|
|
|
|
|
[$res->code, $self->_get_headers($res), $res->content]; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub post_form { |
29
|
|
|
|
|
|
|
my ($self, $url, $form, $headers) = @_; |
30
|
|
|
|
|
|
|
my $res = $self->_client->post($url, $form, %$headers); |
31
|
|
|
|
|
|
|
[$res->code, $self->_get_headers($res), $res->content]; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub post { |
35
|
|
|
|
|
|
|
my ($self, $url, $body, $headers) = @_; |
36
|
|
|
|
|
|
|
my $res = $self->_client->post($url, %$headers, Content => $body); |
37
|
|
|
|
|
|
|
[$res->code, $self->_get_headers($res), $res->content]; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub put { |
41
|
|
|
|
|
|
|
my ($self, $url, $body, $headers) = @_; |
42
|
|
|
|
|
|
|
my $res = $self->_client->put($url, %$headers, Content => $body); |
43
|
|
|
|
|
|
|
[$res->code, $self->_get_headers($res), $res->content]; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub delete { |
47
|
|
|
|
|
|
|
my ($self, $url, $params, $headers) = @_; |
48
|
|
|
|
|
|
|
$url = $self->_param_url($url, $params) if $params; |
49
|
|
|
|
|
|
|
my $res = $self->_client->delete($url, %$headers); |
50
|
|
|
|
|
|
|
[$res->code, $self->_get_headers($res), $res->content]; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub _get_headers { |
54
|
0
|
|
|
0
|
|
|
my ($self, $msg) = @_; |
55
|
0
|
|
|
|
|
|
my $headers = {}; |
56
|
0
|
|
|
|
|
|
for my $key ($msg->header_field_names) { |
57
|
0
|
|
|
|
|
|
$headers->{lc $key} = $msg->header($key); |
58
|
|
|
|
|
|
|
} |
59
|
0
|
|
|
|
|
|
$headers; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
1; |