| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Paws::Net::LWPCaller; |
|
2
|
|
|
|
|
|
|
# This caller uses LWP::UserAgent -- thus HTTPS proxies are supported. |
|
3
|
3
|
|
|
3
|
|
2229
|
use Moose; |
|
|
3
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
18
|
|
|
4
|
|
|
|
|
|
|
with 'Paws::Net::RetryCallerRole', 'Paws::Net::CallerRole'; |
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
has debug => ( is => 'rw', required => 0, default => sub { 0 } ); |
|
7
|
|
|
|
|
|
|
has ua => (is => 'rw', required => 1, lazy => 1, |
|
8
|
|
|
|
|
|
|
default => sub { |
|
9
|
3
|
|
|
3
|
|
22262
|
use LWP::UserAgent; |
|
|
3
|
|
|
|
|
41839
|
|
|
|
3
|
|
|
|
|
629
|
|
|
10
|
|
|
|
|
|
|
my $ua = LWP::UserAgent->new(timeout => 60); |
|
11
|
|
|
|
|
|
|
$ua->env_proxy; |
|
12
|
|
|
|
|
|
|
push @{ $ua->requests_redirectable }, 'POST'; |
|
13
|
|
|
|
|
|
|
return $ua; |
|
14
|
|
|
|
|
|
|
} |
|
15
|
|
|
|
|
|
|
); |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub send_request { |
|
18
|
10
|
|
|
10
|
0
|
43
|
my ($self, $service, $call_object) = @_; |
|
19
|
|
|
|
|
|
|
|
|
20
|
10
|
|
|
|
|
90
|
my $requestObj = $service->prepare_request_for_call($call_object); |
|
21
|
|
|
|
|
|
|
|
|
22
|
10
|
|
|
|
|
35
|
my $headers = $requestObj->header_hash; |
|
23
|
|
|
|
|
|
|
# HTTP::Tiny derives the Host header from the URL. It's an error to set it. |
|
24
|
10
|
|
|
|
|
30
|
delete $headers->{Host}; |
|
25
|
|
|
|
|
|
|
|
|
26
|
10
|
|
|
|
|
257
|
my $method = lc $requestObj->method; |
|
27
|
10
|
50
|
|
|
|
234
|
my $response = $self->ua->$method( |
|
28
|
|
|
|
|
|
|
$requestObj->url, |
|
29
|
|
|
|
|
|
|
%$headers, |
|
30
|
|
|
|
|
|
|
(defined $requestObj->content)?(Content => $requestObj->content):(), |
|
31
|
|
|
|
|
|
|
); |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
|
34
|
10
|
|
|
|
|
66136
|
my $lcheaders = {}; |
|
35
|
10
|
|
|
30
|
|
33
|
$response->headers->scan(sub { $lcheaders->{ lc$_[0] } = $_[1] }); |
|
|
30
|
|
|
|
|
526
|
|
|
36
|
|
|
|
|
|
|
|
|
37
|
10
|
|
|
|
|
73
|
return($response->code, $response->content, $lcheaders); |
|
38
|
|
|
|
|
|
|
} |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub caller_to_response { |
|
41
|
28
|
|
|
28
|
0
|
100
|
my ($self, $service, $call_object, $status, $content, $headers) = @_; |
|
42
|
|
|
|
|
|
|
|
|
43
|
28
|
100
|
66
|
|
|
162
|
if ($status == 500 and $headers->{'client-warning'} eq 'Internal response') { |
|
44
|
15
|
|
|
|
|
367
|
return Paws::Exception->new(message => $content, code => 'ConnectionError', request_id => ''); |
|
45
|
|
|
|
|
|
|
} else { |
|
46
|
13
|
|
|
|
|
65
|
return $service->handle_response($call_object, $status, $content, $headers); |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
} |
|
49
|
|
|
|
|
|
|
1; |