| 1 | package Paws::Net::S3APIRequest; | ||||||||||||
| 2 | 13 | ▶ | use Moose; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 3 | 13 | extends 'Paws::Net::APIRequest'; | |||||||||||
| 4 | |||||||||||||
| 5 | 13 | ▶ | use URI; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 6 | 13 | ▶ | use HTTP::Date 'time2isoz'; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 7 | 13 | ▶ | use MIME::Base64 qw(encode_base64); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 8 | 13 | ▶ | use Digest::MD5 'md5'; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 9 | |||||||||||||
| 10 | 0 | ▶ | has _uri_obj => (is => 'ro', isa => 'URI', lazy => 1, default => sub { | ||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||
| 11 | 0 | return URI->new(shift->url); | |||||||||||
| 12 | 13 | }); | |||||||||||
| 13 | |||||||||||||
| 14 | #Code taken from https://metacpan.org/source/LEEJO/AWS-S3-0.10/lib/AWS/S3/Signer.pm | ||||||||||||
| 15 | has 'bucket_name' => ( | ||||||||||||
| 16 | is => 'ro', | ||||||||||||
| 17 | isa => 'Str', | ||||||||||||
| 18 | required => 1, | ||||||||||||
| 19 | lazy => 1, | ||||||||||||
| 20 | 0 | ▶ | default => sub { | ||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||
| 21 | 0 | my $s = shift; | |||||||||||
| 22 | |||||||||||||
| 23 | 0 | my $endpoint = $s->_uri_obj->host; | |||||||||||
| 24 | 0 | ▶ | if ( my ( $name ) = $endpoint =~ m{^(.+?)\.\Q$endpoint\E} ) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 25 | 0 | return $name; | |||||||||||
| 26 | } else { | ||||||||||||
| 27 | 0 | return ''; | |||||||||||
| 28 | } # end if() | ||||||||||||
| 29 | } | ||||||||||||
| 30 | 13 | ); | |||||||||||
| 31 | |||||||||||||
| 32 | has 'date' => ( | ||||||||||||
| 33 | is => 'ro', | ||||||||||||
| 34 | isa => 'Str', | ||||||||||||
| 35 | 273 | ▶ | default => sub { | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 36 | 273 | my $s = shift; | |||||||||||
| 37 | 273 | my $http_date = time2isoz( time ); | |||||||||||
| 38 | 273 | $http_date =~ s/ /T/g; | |||||||||||
| 39 | 273 | $http_date =~ s/[\:\-]//g; | |||||||||||
| 40 | 273 | return $http_date; | |||||||||||
| 41 | } | ||||||||||||
| 42 | 13 | ); | |||||||||||
| 43 | |||||||||||||
| 44 | has 'content_type' => ( | ||||||||||||
| 45 | is => 'ro', | ||||||||||||
| 46 | isa => 'Str', | ||||||||||||
| 47 | lazy => 1, | ||||||||||||
| 48 | 0 | ▶ | default => sub { | ||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||
| 49 | 0 | my $s = shift; | |||||||||||
| 50 | 0 | ▶ | return '' if $s->method eq 'GET'; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 51 | 0 | ▶ | return '' unless $s->content; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 52 | 0 | return 'text/plain'; | |||||||||||
| 53 | } | ||||||||||||
| 54 | 13 | ); | |||||||||||
| 55 | |||||||||||||
| 56 | has 'content_md5' => ( | ||||||||||||
| 57 | is => 'ro', | ||||||||||||
| 58 | isa => 'Str', | ||||||||||||
| 59 | lazy => 1, | ||||||||||||
| 60 | 0 | ▶ | default => sub { | ||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||
| 61 | 0 | my $s = shift; | |||||||||||
| 62 | 0 | ▶ | return '' unless $s->content; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 63 | 0 | return encode_base64( md5( ${ $s->content } ), '' ); | |||||||||||
| 64 | } | ||||||||||||
| 65 | 13 | ); | |||||||||||
| 66 | |||||||||||||
| 67 | has 'content_length' => ( | ||||||||||||
| 68 | is => 'ro', | ||||||||||||
| 69 | isa => 'Int|Undef', | ||||||||||||
| 70 | lazy => 1, | ||||||||||||
| 71 | 52 | ▶ | default => sub { length( shift->content || q[] ) } | ||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Condition100%2/2
(shift())->content || ''
MC/DC100%1/1
(shift())->content || ''
(shift())->content
Truth table100%2/2
A
A= (shift())->content
| |||||||||||||
| 72 | 13 | ); | |||||||||||
| 73 | |||||||||||||
| 74 | 0 | ▶ | sub _trim { | ||||||||||
|
Subroutine
_trim: not called CC=1 SCAR=6.9
| |||||||||||||
| 75 | 0 | my ( $value ) = @_; | |||||||||||
| 76 | 0 | $value =~ s/^\s+//; | |||||||||||
| 77 | 0 | $value =~ s/\s+$//; | |||||||||||
| 78 | 0 | return $value; | |||||||||||
| 79 | } | ||||||||||||
| 80 | 13 | 1; | |||||||||||