| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Docker::Registry::IO::Simple; | 
| 2 | 1 |  |  | 1 |  | 8 | use Moo; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 10 |  | 
| 3 | 1 |  |  | 1 |  | 474 | use Types::Standard qw/Bool/; | 
|  | 1 |  |  |  |  | 3 |  | 
|  | 1 |  |  |  |  | 13 |  | 
| 4 |  |  |  |  |  |  | with 'Docker::Registry::IO'; | 
| 5 |  |  |  |  |  |  |  | 
| 6 | 1 |  |  | 1 |  | 1440 | use HTTP::Tiny; | 
|  | 1 |  |  |  |  | 42351 |  | 
|  | 1 |  |  |  |  | 41 |  | 
| 7 | 1 |  |  | 1 |  | 628 | use Data::Dumper; | 
|  | 1 |  |  |  |  | 6161 |  | 
|  | 1 |  |  |  |  | 238 |  | 
| 8 |  |  |  |  |  |  |  | 
| 9 |  |  |  |  |  |  | has debug => (is => 'rw', isa => Bool, default => 0); | 
| 10 |  |  |  |  |  |  |  | 
| 11 |  |  |  |  |  |  | has ua => (is => 'ro', default => sub { | 
| 12 |  |  |  |  |  |  | HTTP::Tiny->new( | 
| 13 |  |  |  |  |  |  | max_redirect => 0, | 
| 14 |  |  |  |  |  |  | agent => 'Docker::Registry Perl client' . $Docker::Registry::VERSION, | 
| 15 |  |  |  |  |  |  | timeout => 60, | 
| 16 |  |  |  |  |  |  | ); | 
| 17 |  |  |  |  |  |  | }); | 
| 18 |  |  |  |  |  |  |  | 
| 19 |  |  |  |  |  |  | sub send_request { | 
| 20 | 0 |  |  | 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 | 0 |  |  |  |  | print Dumper($request) if ($self->debug); | 
| 27 |  |  |  |  |  |  |  | 
| 28 | 0 | 0 |  |  |  |  | my $response = $self->ua->request( | 
| 29 |  |  |  |  |  |  | $request->method, | 
| 30 |  |  |  |  |  |  | $request->url, | 
| 31 |  |  |  |  |  |  | { | 
| 32 |  |  |  |  |  |  | headers => $headers, | 
| 33 |  |  |  |  |  |  | (defined $request->content)?(content => $request->content):(), | 
| 34 |  |  |  |  |  |  | } | 
| 35 |  |  |  |  |  |  | ); | 
| 36 | 0 | 0 |  |  |  |  | print Dumper($response) if ($self->debug); | 
| 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; |