blib/lib/Paws/Net/FurlCaller.pm

filter: Statementstmt 66.6% 4 / 6 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 2 / 2 Podpod n/a totaltotal 75.0% 6 / 8 CC 1 SCAR 1.4
CC
1
Cov
67%
BEGIN
1.3
BEGIN
1.0
CRAP 1.1
« blib/lib/Paws/Net/FileMockCaller.pm ↑ Summary blib/lib/Paws/Net/MojoAsyncCaller.pm »
1 package Paws::Net::FurlCaller;
2 # This caller uses Furl
3 3 ▶ use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 with 'Paws::Net::RetryCallerRole', 'Paws::Net::CallerRole';
5 0 ▶ use Furl;
Subroutine BEGIN: called CC=1 SCAR=2.6
6 use Paws::Net::APIResponse;
7  
8 has debug => ( is => 'rw', required => 0, default => sub { 0 } );
9 has ua => (is => 'rw', required => 1, lazy => 1,
10 default => sub {
11 my $ua = Furl->new(
12 timeout => 60,
13 agent => 'AWS Perl SDK ' . $Paws::VERSION,
14 );
15 return $ua;
16 }
17 );
18  
19 sub send_request {
20 my ($self, $service, $call_object) = @_;
21 my $requestObj = $service->prepare_request_for_call($call_object);
22  
23 my $headers = $requestObj->header_hash;
24 # HTTP::Tiny derives the Host header from the URL. It's an error to set it.
25 delete $headers->{Host};
26  
27 my $method = uc $requestObj->method;
28 my $response = $self->ua->request(
29 url => $requestObj->url,
30 headers => [ %$headers ],
31 method => $method,
32 (defined $requestObj->content)?(content => $requestObj->content):(),
33 );
34  
35 return Paws::Net::APIResponse->new(
36 status => $response->code,
37 content => $response->content,
38 headers => { $response->headers->flatten },
39 );
40 }
41  
42 sub caller_to_response {
43 my ($self, $service, $call_object, $response) = @_;
44
45 if ($response->status == 500 and $response->has_header('x-internal-response')) {
46 return Paws::Exception->new(message => $response->content, code => 'ConnectionError', request_id => '');
47 } else {
48 return $service->response_to_object->process($call_object, $response);
49 }
50 }
51 1;
« blib/lib/Paws/Net/FileMockCaller.pm ↑ Summary blib/lib/Paws/Net/MojoAsyncCaller.pm »