« lib/WWW/Hetzner/Robot/CLI/Cmd/Boot/Cmd/Rescue.pm
↑ Summary
lib/WWW/Hetzner/CLI/Cmd/LoadBalancer/Cmd/List.pm »
| 1 | package WWW::Hetzner::LWPIO; | ||||||||||||
| 2 | |||||||||||||
| 3 | # ABSTRACT: Synchronous HTTP backend using LWP::UserAgent | ||||||||||||
| 4 | |||||||||||||
| 5 | 56 | ▶ | use Moo; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 6 | 56 | ▶ | use LWP::UserAgent; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 7 | 56 | ▶ | use HTTP::Request; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 8 | 56 | ▶ | use WWW::Hetzner::HTTPResponse; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 9 | |||||||||||||
| 10 | 56 | with 'WWW::Hetzner::Role::IO'; | |||||||||||
| 11 | |||||||||||||
| 12 | 56 | our $VERSION = '0.101'; | |||||||||||
| 13 | |||||||||||||
| 14 | |||||||||||||
| 15 | 56 | has timeout => (is => 'ro', default => 30); | |||||||||||
| 16 | |||||||||||||
| 17 | |||||||||||||
| 18 | has ua => ( | ||||||||||||
| 19 | is => 'lazy', | ||||||||||||
| 20 | 0 | ▶ | builder => sub { | ||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
Subroutine
_build_ua: called CC=1 SCAR=1.2
| |||||||||||||
| 21 | 0 | my $self = shift; | |||||||||||
| 22 | 0 | LWP::UserAgent->new( | |||||||||||
| 23 | agent => 'WWW-Hetzner/' . $VERSION, | ||||||||||||
| 24 | timeout => $self->timeout, | ||||||||||||
| 25 | ); | ||||||||||||
| 26 | }, | ||||||||||||
| 27 | 56 | ); | |||||||||||
| 28 | |||||||||||||
| 29 | |||||||||||||
| 30 | 0 | ▶ | sub call { | ||||||||||
|
Subroutine
call: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||
| 31 | 0 | my ($self, $req) = @_; | |||||||||||
| 32 | |||||||||||||
| 33 | 0 | my $http_req = HTTP::Request->new($req->method => $req->url); | |||||||||||
| 34 | |||||||||||||
| 35 | 0 | my $headers = $req->headers; | |||||||||||
| 36 | 0 | for my $header (keys %$headers) { | |||||||||||
| 37 | 0 | $http_req->header($header => $headers->{$header}); | |||||||||||
| 38 | } | ||||||||||||
| 39 | |||||||||||||
| 40 | 0 | ▶ | $http_req->content($req->content) if $req->has_content; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 41 | |||||||||||||
| 42 | 0 | my $response = $self->ua->request($http_req); | |||||||||||
| 43 | |||||||||||||
| 44 | 0 | ▶ | return WWW::Hetzner::HTTPResponse->new( | ||||||||||
|
Condition0%0/2
$response->decoded_content // ""
MC/DC0%0/1
$response->decoded_content // ""
$response->decoded_content
Truth table0%0/2
A
A= $response->decoded_content
| |||||||||||||
| 45 | status => $response->code, | ||||||||||||
| 46 | content => $response->decoded_content // '', | ||||||||||||
| 47 | ); | ||||||||||||
| 48 | } | ||||||||||||
| 49 | |||||||||||||
| 50 | |||||||||||||
| 51 | |||||||||||||
| 52 | 56 | 1; | |||||||||||
| 53 | |||||||||||||
| 54 | __END__ | ||||||||||||