blib/lib/Amazon/Credentials/HTTP/UserAgent.pm

filter: Statementstmt 55.5% 15 / 27 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 71.4% 5 / 7 Podpod 0.0% 0 / 2 totaltotal 50.0% 20 / 40 CC 3 SCAR 11.7
CC
3
Cov
48%
request
6.0
__ANON__
6.0
BEGIN
1.0
CRAP 3.2
« blib/lib/Amazon/Credentials/Role/File.pm ↑ Summary UnitTest.pm »
1 package Amazon::Credentials::HTTP::UserAgent;
2  
3 18 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 18 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 18 ▶use HTTP::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 18 ▶use Amazon::Credentials::HTTP::Response;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 ########################################################################
10 24 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
11 ########################################################################
12 24 my ( $class, %opts ) = @_;
13  
14 24 return bless { ua => HTTP::Tiny->new(%opts) }, $class;
15 }
16  
17 ########################################################################
18 0 ▶sub request {
Subroutine request: not called CC=2 SCAR=17.9
Pod undocumented
19 ########################################################################
20 0 my ( $self, $request ) = @_;
21  
22 0 my %headers;
23  
24 $request->headers->scan(
25 0 ▶ sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
26 0 my ( $field, $value ) = @_;
27  
28 0 ▶ return if lc $field eq 'host';
Branch: 1 branch
BranchTrueFalseTotal
if lc $field eq "host" 0 0 0
29  
30 # HTTP::Headers keeps an underscore in a field name only when the name
31 # carries a leading ':' sigil (which suppresses its _ -> - translation).
32 # That sigil is private to HTTP::Headers and is stripped when it
33 # serializes (see HTTP::Headers::as_string). We bypass that serialization
34 # and hand names straight to HTTP::Tiny, so we must strip it ourselves --
35 # otherwise the ':' reaches HTTP::Tiny, which rejects it as an invalid
36 # field-name character (e.g. the x-amz-sso_bearer_token SSO header).
37 0 $field =~ s/^://xsm;
38  
39 0 $headers{$field} = $value;
40 }
41 0 );
42  
43 0 my %opts = ( headers => \%headers );
44  
45 0 ▶ if ( my $content = $request->content ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $content = $request->content) 0 0 0
46 0 $opts{content} = $content;
47 }
48  
49 0 my $response = $self->{ua}->request( $request->method, $request->uri->as_string, \%opts );
50  
51 0 return Amazon::Credentials::HTTP::Response->new($response);
52 }
53  
54 18 1;
« blib/lib/Amazon/Credentials/Role/File.pm ↑ Summary UnitTest.pm »