S3/HTTPRequest.pm

filter: Statementstmt 97.8% 45 / 46 Branchbran 100% 6 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 88.8% 8 / 9 Podpod 0.0% 0 / 1 totaltotal 95.1% 59 / 62 CC 4 SCAR 7.0
CC
4
Cov
98%
http_request
4.0
__ANON__
1.1
BEGIN
1.0
CRAP 2.0
« S3/Request/CreateBucket.pm ↑ Summary S3/Request/GetBucketAccessControl.pm »
1  
2 package AWS::S3::HTTPRequest;
3  
4 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Moose::Util::TypeConstraints;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use AWS::S3::Signer;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 ▶use HTTP::Headers;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use URI;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 1 with 'AWS::S3::Roles::Bucket';
12  
13 1 my $METADATA_PREFIX = 'x-amz-meta-';
14 1 my $AMAZON_HEADER_PREFIX = 'x-amz-';
15  
16 1 enum 'HTTPMethod' => [qw( HEAD GET PUT POST DELETE )];
17  
18 1 has 's3' => (
19 is => 'ro',
20 required => 1,
21 isa => 'AWS::S3',
22 );
23  
24 1 has 'method' => (
25 is => 'ro',
26 required => 1,
27 isa => 'HTTPMethod'
28 );
29  
30 1 has 'path' => (
31 is => 'ro',
32 required => 1,
33 isa => 'Str',
34 );
35  
36 1 class_type( 'HTTP::Headers' );
37  
38 coerce 'HTTP::Headers'
39 => from 'HashRef'
40 0 ▶ => via { my $h = HTTP::Headers->new( %$_ ) };
Subroutine __ANON__: not called CC=1 SCAR=1.2
41  
42 has 'headers' => (
43 is => 'ro',
44 required => 1,
45 isa => 'HTTP::Headers',
46 lazy => 1,
47 2 ▶ default => sub { HTTP::Headers->new() },
Subroutine __ANON__: called CC=1 SCAR=0.0
48 1 coerce => 1,
49 );
50  
51 1 has 'content' => (
52 is => 'ro',
53 required => 1,
54 isa => 'Str|ScalarRef|CodeRef',
55 default => '',
56 );
57  
58 has 'metadata' => (
59 is => 'ro',
60 required => 1,
61 isa => 'HashRef',
62 2 ▶ default => sub { {} },
Subroutine __ANON__: called CC=1 SCAR=0.0
63 1 );
64  
65 1 has 'contenttype' => (
66 is => 'ro',
67 required => 0,
68 isa => 'Str',
69 );
70  
71 # Make the HTTP::Request object:
72 2 ▶sub http_request {
Subroutine http_request: called CC=4 SCAR=13.9
Pod undocumented
73 2 my $s = shift;
74 2 my $method = $s->method;
75 2 my $headers = $s->headers;
76 2 my $content = $s->content;
77 2 my $metadata = $s->metadata;
78  
79 2 my $uri = $s->bucket_uri( $s->path );
80  
81 2 ▶ my $signer = AWS::S3::Signer->new(
Branch: 1 branch
BranchTrueFalseTotal
$content ? : 1 1 2
82 s3 => $s->s3,
83 method => $method,
84 uri => $uri,
85 content => $content ? \$content : undef,
86 headers => [ $headers->flatten ],
87 );
88  
89 2 $headers->header( 'Authorization' => $signer->auth_header );
90 2 $headers->header( 'Date' => $signer->date );
91 2 $headers->header( 'Host' => URI->new( $uri )->host );
92 2 ▶ $headers->header( 'content-length' => $signer->content_length ) if $content;
Branch: 1 branch
BranchTrueFalseTotal
if $content 1 1 2
93 2 ▶ $headers->header( 'content-type' => $signer->content_type ) if $content;
Branch: 1 branch
BranchTrueFalseTotal
if $content 1 1 2
94  
95 2 my $request = HTTP::Request->new( $method, $uri, $headers, $content );
96  
97 2 return $request;
98 } # end http_request()
99  
100 1 __PACKAGE__->meta->make_immutable;
101  
« S3/Request/CreateBucket.pm ↑ Summary S3/Request/GetBucketAccessControl.pm »