| 1 | package Docker::Registry::IO::Simple; | ||||||||||
| 2 | 1 | ▶ | use Moo; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 1 | ▶ | use Types::Standard qw/Bool/; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 1 | with 'Docker::Registry::IO'; | |||||||||
| 5 | |||||||||||
| 6 | 1 | ▶ | use HTTP::Tiny; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 1 | ▶ | use Data::Dumper; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | 1 | has debug => (is => 'rw', isa => Bool, default => 0); | |||||||||
| 10 | |||||||||||
| 11 | 1 | ▶ | has ua => (is => 'ro', default => sub { | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 12 | 1 | HTTP::Tiny->new( | |||||||||
| 13 | max_redirect => 0, | ||||||||||
| 14 | agent => 'Docker::Registry Perl client' . $Docker::Registry::VERSION, | ||||||||||
| 15 | timeout => 60, | ||||||||||
| 16 | ); | ||||||||||
| 17 | 1 | }); | |||||||||
| 18 | |||||||||||
| 19 | 0 | ▶ | sub send_request { | ||||||||
|
Subroutine
send_request: not called CC=4 SCAR=30.0
| |||||||||||
| 20 | 0 | my ($self, $request) = @_; | |||||||||
| 21 | 0 | my $headers = $request->header_hash; | |||||||||
| 22 | |||||||||||
| 23 | # HTTP::Tiny derives the Host header from the URL. It's an error to set it. | ||||||||||
| 24 | 0 | delete $headers->{Host}; | |||||||||
| 25 | |||||||||||
| 26 | 0 | ▶ | print Dumper($request) if ($self->debug); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 27 | |||||||||||
| 28 | 0 | ▶ | my $response = $self->ua->request( | ||||||||
|
Branch: 1 branch
| |||||||||||
| 29 | $request->method, | ||||||||||
| 30 | $request->url, | ||||||||||
| 31 | { | ||||||||||
| 32 | headers => $headers, | ||||||||||
| 33 | (defined $request->content)?(content => $request->content):(), | ||||||||||
| 34 | } | ||||||||||
| 35 | ); | ||||||||||
| 36 | 0 | ▶ | print Dumper($response) if ($self->debug); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 37 | |||||||||||
| 38 | return Docker::Registry::Response->new( | ||||||||||
| 39 | status => $response->{status}, | ||||||||||
| 40 | content => $response->{content}, | ||||||||||
| 41 | headers => $response->{headers} | ||||||||||
| 42 | 0 | ); | |||||||||
| 43 | } | ||||||||||
| 44 | |||||||||||
| 45 | 1 | 1; | |||||||||