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   3915 use Moose;
  10         20  
  10         358  
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   61651 use HTTP::Tiny;
  10         290305  
  10         1876  
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 37 my ($self, $service, $call_object) = @_;
18 10         85 my $requestObj = $service->prepare_request_for_call($call_object);
19 10         39 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         32 delete $headers->{Host};
23              
24 10 50       300 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         492264 return ($response->{status}, $response->{content}, $response->{headers});
33             }
34              
35             sub caller_to_response {
36 82     82 0 273 my ($self, $service, $call_object, $status, $content, $headers) = @_;
37 82 100       287 if ($status == 599){
38 15         402 return Paws::Exception->new(message => $content, code => 'ConnectionError', request_id => '');
39             } else {
40 67         340 return $service->handle_response($call_object, $status, $content, $headers);
41             }
42             }
43             1;