File Coverage

blib/lib/Paws/Net/Caller.pm
Criterion Covered Total %
statement 16 16 100.0
branch 3 4 75.0
condition n/a
subroutine 4 4 100.0
pod 0 2 0.0
total 23 26 88.4


line stmt bran cond sub pod time code
1             package Paws::Net::Caller;
2 10     10   13559 use Moose;
  10         82  
  10         71  
3             with 'Paws::Net::RetryCallerRole', 'Paws::Net::CallerRole';
4              
5             has debug => ( is => 'rw', required => 0, default => sub { 0 } );
6             has ua => (is => 'rw', required => 1, lazy => 1,
7             default => sub {
8 10     10   89084 use HTTP::Tiny;
  10         327667  
  10         2151  
9             HTTP::Tiny->new(
10             agent => 'AWS Perl SDK ' . $Paws::VERSION,
11             timeout => 60,
12             );
13             }
14             );
15              
16             sub send_request {
17 10     10 0 34 my ($self, $service, $call_object) = @_;
18 10         89 my $requestObj = $service->prepare_request_for_call($call_object);
19 10         53 my $headers = $requestObj->header_hash;
20              
21             # HTTP::Tiny derives the Host header from the URL. It's an error to set it.
22 10         27 delete $headers->{Host};
23              
24 10 50       270 my $response = $self->ua->request(
25             $requestObj->method,
26             $requestObj->url,
27             {
28             headers => $headers,
29             (defined $requestObj->content)?(content => $requestObj->content):(),
30             }
31             );
32 10         421274 return ($response->{status}, $response->{content}, $response->{headers});
33             }
34              
35             sub caller_to_response {
36 82     82 0 307 my ($self, $service, $call_object, $status, $content, $headers) = @_;
37 82 100       347 if ($status == 599){
38 15         491 return Paws::Exception->new(message => $content, code => 'ConnectionError', request_id => '');
39             } else {
40 67         422 return $service->handle_response($call_object, $status, $content, $headers);
41             }
42             }
43             1;