blib/lib/Paws/Net/LWPCaller.pm

filter: Statementstmt 100% 33 / 33 Branchbran 75.0% 3 / 4 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 8 / 8 Podpod 0.0% 0 / 2 totaltotal 90.3% 47 / 52 CC 4 SCAR 5.5
CC
4
Cov
95%
caller_to_response
3.0
send_request
2.0
BEGIN
1.0
CRAP 1.7
« blib/lib/Paws/Pinpoint.pm ↑ Summary blib/lib/Paws/API/JSONAttribute.pm »
1 package Paws::Net::LWPCaller;
2 # This caller uses LWP::UserAgent -- thus HTTPS proxies are supported.
3 3 ▶ use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 with 'Paws::Net::RetryCallerRole', 'Paws::Net::CallerRole';
5 3 ▶ use Paws::Net::APIResponse;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 3 ▶ has debug => ( is => 'rw', required => 0, default => sub { 0 } );
Subroutine __ANON__: called CC=1 SCAR=0.0
8 has ua => (is => 'rw', required => 1, lazy => 1,
9 2 ▶ default => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
10 3 ▶ use LWP::UserAgent;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 my $ua = LWP::UserAgent->new(timeout => 60);
12 2 $ua->env_proxy;
13 2 push @{ $ua->requests_redirectable }, 'POST';
14 2 return $ua;
15 }
16 3 );
17  
18 10 ▶ sub send_request {
Subroutine send_request: called CC=2 SCAR=6.9
Pod undocumented
19 10 my ($self, $service, $call_object) = @_;
20  
21 10 my $requestObj = $service->prepare_request_for_call($call_object);
22  
23 10 my $headers = $requestObj->header_hash;
24 # HTTP::Tiny derives the Host header from the URL. It's an error to set it.
25 10 delete $headers->{Host};
26  
27 10 my $method = lc $requestObj->method;
28 10 ▶ my $response = $self->ua->$method(
Branch: 1 branch
BranchTrueFalseTotal
defined $requestObj->content ? : 10 0 10
29 $requestObj->url,
30 %$headers,
31 (defined $requestObj->content)?(Content => $requestObj->content):(),
32 );
33
34  
35 10 my $lcheaders = {};
36 10 ▶ $response->headers->scan(sub { $lcheaders->{ lc$_[0] } = $_[1] });
Subroutine __ANON__: called CC=1 SCAR=0.0
37  
38 10 return Paws::Net::APIResponse->new(
39 status => $response->code,
40 content => $response->content,
41 headers => $lcheaders,
42 );
43 }
44  
45 28 ▶ sub caller_to_response {
Subroutine caller_to_response: called CC=3 SCAR=11.0
Pod undocumented
46 28 my ($self, $service, $call_object, $response) = @_;
47
48 28 ▶ if ($response->status == 500 and $response->header('client-warning') eq 'Internal response') {
Branch: 1 branch
BranchTrueFalseTotal
if ($response->status == 500 and $response->header('client-warning') eq 'Internal response') { } 15 13 28
Condition66%2/3
$response->status == 500 and $response->header("client-warning") eq "Internal response"
!ll&&!rl&&r
13015
MC/DC50%1/2
$response->status == 500 and $response->header("client-warning") eq "Internal response"
$response->status == 500 $response->header("client-warning") eq "Internal response"
Truth table66%2/3
A and B
A= $response->status == 500B= $response->header("client-warning") eq "Internal response"
ABresult
0X0
100
111
49 15 return Paws::Exception->new(message => $response->content, code => 'ConnectionError', request_id => '');
50 } else {
51 13 return $service->response_to_object->process($call_object, $response);
52 }
53 }
54 3 1;
« blib/lib/Paws/Pinpoint.pm ↑ Summary blib/lib/Paws/API/JSONAttribute.pm »