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   5569 use Moose;
  10         27  
  10         359  
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   77235 use HTTP::Tiny;
  10         398312  
  10         2242  
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 44 my ($self, $service, $call_object) = @_;
18 10         101 my $requestObj = $service->prepare_request_for_call($call_object);
19 10         50 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         37 delete $headers->{Host};
23              
24 10 50       356 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         436742 return ($response->{status}, $response->{content}, $response->{headers});
33             }
34              
35             sub caller_to_response {
36 82     82 0 388 my ($self, $service, $call_object, $status, $content, $headers) = @_;
37 82 100       646 if ($status == 599){
38 15         495 return Paws::Exception->new(message => $content, code => 'ConnectionError', request_id => '');
39             } else {
40 67         532 return $service->handle_response($call_object, $status, $content, $headers);
41             }
42             }
43             1;