| 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
| |||||||||||||||||||||||||||||
| 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
Condition66%2/3
$response->status == 500 and $response->header("client-warning") eq "Internal response"
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"
| |||||||||||||||||||||||||||||
| 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; | |||||||||||||||||||||||||||