line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
package AWS::S3::HTTPRequest; |
3
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
2151
|
use Moose; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
5
|
|
5
|
1
|
|
|
1
|
|
4001
|
use Moose::Util::TypeConstraints; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
6
|
1
|
|
|
1
|
|
1555
|
use AWS::S3::Signer; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
38
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
8
|
use HTTP::Headers; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
25
|
|
9
|
1
|
|
|
1
|
|
3
|
use URI; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
371
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
with 'AWS::S3::Roles::Bucket'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
my $METADATA_PREFIX = 'x-amz-meta-'; |
14
|
|
|
|
|
|
|
my $AMAZON_HEADER_PREFIX = 'x-amz-'; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
enum 'HTTPMethod' => [qw( HEAD GET PUT POST DELETE )]; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
has 's3' => ( |
19
|
|
|
|
|
|
|
is => 'ro', |
20
|
|
|
|
|
|
|
required => 1, |
21
|
|
|
|
|
|
|
isa => 'AWS::S3', |
22
|
|
|
|
|
|
|
); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
has 'method' => ( |
25
|
|
|
|
|
|
|
is => 'ro', |
26
|
|
|
|
|
|
|
required => 1, |
27
|
|
|
|
|
|
|
isa => 'HTTPMethod' |
28
|
|
|
|
|
|
|
); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
has 'path' => ( |
31
|
|
|
|
|
|
|
is => 'ro', |
32
|
|
|
|
|
|
|
required => 1, |
33
|
|
|
|
|
|
|
isa => 'Str', |
34
|
|
|
|
|
|
|
); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
class_type( 'HTTP::Headers' ); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
coerce 'HTTP::Headers' |
39
|
|
|
|
|
|
|
=> from 'HashRef' |
40
|
|
|
|
|
|
|
=> via { my $h = HTTP::Headers->new( %$_ ) }; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
has 'headers' => ( |
43
|
|
|
|
|
|
|
is => 'ro', |
44
|
|
|
|
|
|
|
required => 1, |
45
|
|
|
|
|
|
|
isa => 'HTTP::Headers', |
46
|
|
|
|
|
|
|
lazy => 1, |
47
|
|
|
|
|
|
|
default => sub { HTTP::Headers->new() }, |
48
|
|
|
|
|
|
|
coerce => 1, |
49
|
|
|
|
|
|
|
); |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
default => sub { {} }, |
63
|
|
|
|
|
|
|
); |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
has 'contenttype' => ( |
66
|
|
|
|
|
|
|
is => 'ro', |
67
|
|
|
|
|
|
|
required => 0, |
68
|
|
|
|
|
|
|
isa => 'Str', |
69
|
|
|
|
|
|
|
); |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
# Make the HTTP::Request object: |
72
|
|
|
|
|
|
|
sub http_request { |
73
|
1
|
|
|
1
|
0
|
2
|
my $s = shift; |
74
|
1
|
|
|
|
|
29
|
my $method = $s->method; |
75
|
1
|
|
|
|
|
23
|
my $headers = $s->headers; |
76
|
1
|
|
|
|
|
23
|
my $content = $s->content; |
77
|
1
|
|
|
|
|
22
|
my $metadata = $s->metadata; |
78
|
|
|
|
|
|
|
|
79
|
1
|
|
|
|
|
22
|
my $uri = $s->bucket_uri( $s->path ); |
80
|
|
|
|
|
|
|
|
81
|
0
|
0
|
|
|
|
|
my $signer = AWS::S3::Signer->new( |
82
|
|
|
|
|
|
|
s3 => $s->s3, |
83
|
|
|
|
|
|
|
method => $method, |
84
|
|
|
|
|
|
|
uri => $uri, |
85
|
|
|
|
|
|
|
content => $content ? \$content : undef, |
86
|
|
|
|
|
|
|
headers => [ $headers->flatten ], |
87
|
|
|
|
|
|
|
); |
88
|
|
|
|
|
|
|
|
89
|
0
|
|
|
|
|
|
$headers->header( 'Authorization' => $signer->auth_header ); |
90
|
0
|
|
|
|
|
|
$headers->header( 'Date' => $signer->date ); |
91
|
0
|
|
|
|
|
|
$headers->header( 'Host' => URI->new( $uri )->host ); |
92
|
0
|
0
|
|
|
|
|
$headers->header( 'content-length' => $signer->content_length ) if $content; |
93
|
0
|
0
|
|
|
|
|
$headers->header( 'content-type' => $signer->content_type ) if $content; |
94
|
|
|
|
|
|
|
|
95
|
0
|
|
|
|
|
|
my $request = HTTP::Request->new( $method, $uri, $headers, $content ); |
96
|
|
|
|
|
|
|
|
97
|
0
|
|
|
|
|
|
return $request; |
98
|
|
|
|
|
|
|
} # end http_request() |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
101
|
|
|
|
|
|
|
|