| 1 | package Net::Respite::Client; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | # Net::Respite::Client - Generic class for running remote services | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 4 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 4 | ▶ | use base 'Net::Respite::Common'; # Default _configs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 4 | ▶ | use IO::Socket::SSL (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 4 | ▶ | use Time::HiRes qw(sleep); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 4 | ▶ | use Digest::MD5 qw(md5_hex); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 4 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=2 SCAR=16.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 4 | ▶ | if (! eval { require Throw }) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 0 | ▶ | *Throw_::TO_JSON = sub { +{%{$_[0]}} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 0 | ▶ | *Throw_::_str = sub { my ($s) = @_; my ($e,$p) = delete(@$s{qw(error _pretty)}); $e||="throw"; $e .= ': '.($p||$Throw::pretty?jsop():json())->encode($s) if %$s; "$e\n" }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=5 SCAR=34.0
Branch: 2 branches
Condition0%0/5
$e ||= "throw"
$p or $Throw::pretty
MC/DC0%0/1
$e ||= "throw"
$e
MC/DC0%0/2
$p or $Throw::pretty
$p
$Throw::pretty
Truth table0%0/2
A
A= $e
Truth table0%0/3
A or B
A= $pB= $Throw::pretty
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 0 | ▶ | *throw = *Throw_::throw = sub { my ($m,$a,$l)=@_; $a=ref($m) ? $m : {%{$a||{}}, error => $m}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=7 SCAR=40.3
Branch: 1 branch
Condition0%0/2
$a || {}
MC/DC0%0/1
$a || {}
$a
Truth table0%0/2
A
A= $a
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 0 | ▶ | do {my$i=$l||0;$i++while __PACKAGE__ eq caller$i; $a->{'trace'}=sprintf "%s at %s line %s\n",(caller$i)[3,1,2]} if $a->{'trace'}||$l; die bless $a, 'Throw_' }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/5
$a->{"trace"} or $l
$l || 0
MC/DC0%0/2
$a->{"trace"} or $l
$a->{"trace"}
$l
MC/DC0%0/1
$l || 0
$l
Truth table0%0/3
A or B
A= $a->{"trace"}B= $l
Truth table0%0/2
A
A= $l
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 0 | overload::OVERLOAD('Throw_', '""' => \&Throw_::_str, fallback => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 4 | } else { Throw->import('throw') } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 14 | ▶ | sub service_name { $_[0]->{'service_name'} || $_[0]->{'service'} || throw "Missing service_name" } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
service_name: called CC=3 SCAR=14.2
Pod
documented
Branch: 1 branch
Condition33%1/3
$_[0]{"service_name"} or $_[0]{"service"}
MC/DC0%0/2
$_[0]{"service_name"} or $_[0]{"service"}
$_[0]{"service_name"}
$_[0]{"service"}
Truth table33%1/3
A or B
A= $_[0]{"service_name"}B= $_[0]{"service"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 7 | ▶ | sub run_method { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run_method: called CC=21 SCAR=40.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 7 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 7 | my $name = $self->service_name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 7 | ▶ | my $method = shift || throw "Missing $name service method", undef, 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
shift() || throw("Missing $name service method", undef, 1)
MC/DC0%0/2
shift() || throw("Missing $name service method", undef, 1)
shift()
throw("Missing $name service method", undef, 1)
Truth table33%1/3
A || B
A= shift()B= throw("Missing $name service method", undef, 1)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 7 | ▶ | my $args = shift || {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift() || {}
MC/DC0%0/1
shift() || {}
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 7 | ▶ | throw "Invalid $name service args", {method => $method, args => $args}, 1 if ref($args) ne 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 7 | ▶ | local $args->{'_i'} = $self->{'remote_ip'} || $ENV{'REMOTE_ADDR'} || (($ENV{'REALUSER'} || $ENV{'SUDO_USER'}) ? 'sudo' : 'cmdline'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%3/9
$self->{'remote_ip'} || $ENV{'REMOTE_ADDR'} || ($ENV{'REALUSER'} || $ENV{'SUDO_USER'} ? 'sudo' : 'cmdline')
$self->{"remote_ip"} or $ENV{"REMOTE_ADDR"}
$ENV{"REALUSER"} or $ENV{"SUDO_USER"}
MC/DC0%0/4
$self->{'remote_ip'} || $ENV{'REMOTE_ADDR'} || ($ENV{'REALUSER'} || $ENV{'SUDO_USER'} ? 'sudo' : 'cmdline')
$self->{"remote_ip"}
$ENV{"REMOTE_ADDR"}
$ENV{"REALUSER"}
$ENV{"SUDO_USER"}
Truth table20%1/5
A or B || C or D
A= $self->{"remote_ip"}B= $ENV{"REMOTE_ADDR"}C= $ENV{"REALUSER"}D= $ENV{"SUDO_USER"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 7 | ▶ | local $args->{'_w'} = $self->{'remote_user'} || $ENV{'REALUSER'} || $ENV{'SUDO_USER'} || $ENV{'REMOTE_USER'} || $ENV{'USER'} || (getpwuid($<))[0] || '-unknown-'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition35%6/17
$self->{'remote_user'} || $ENV{'REALUSER'} || $ENV{'SUDO_USER'} || $ENV{'REMOTE_USER'} || $ENV{'USER'} || (getpwuid $<)[0] || '-unknown-'
$self->{"remote_user"} or $ENV{"REALUSER"} or $ENV{"SUDO_USER"} or $ENV{"REMOTE_USER"} or $ENV{"USER"} or (getpwuid $<)[0]
$self->{"remote_user"} or $ENV{"REALUSER"} or $ENV{"SUDO_USER"} or $ENV{"REMOTE_USER"} or $ENV{"USER"}
$self->{"remote_user"} or $ENV{"REALUSER"} or $ENV{"SUDO_USER"} or $ENV{"REMOTE_USER"}
$self->{"remote_user"} or $ENV{"REALUSER"} or $ENV{"SUDO_USER"}
$self->{"remote_user"} or $ENV{"REALUSER"}
MC/DC0%0/6
$self->{'remote_user'} || $ENV{'REALUSER'} || $ENV{'SUDO_USER'} || $ENV{'REMOTE_USER'} || $ENV{'USER'} || (getpwuid $<)[0] || '-unknown-'
$self->{"remote_user"}
$ENV{"REALUSER"}
$ENV{"SUDO_USER"}
$ENV{"REMOTE_USER"}
$ENV{"USER"}
(getpwuid $<)[0]
Truth table14%1/7
A or B or C or D or E or F
A= $self->{"remote_user"}B= $ENV{"REALUSER"}C= $ENV{"SUDO_USER"}D= $ENV{"REMOTE_USER"}E= $ENV{"USER"}F= (getpwuid $<)[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 7 | ▶ | local $args->{'_t'} = $self->{'token'} if !$args->{'_t'} && $self->{'token'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not $args->{"_t"} and $self->{"token"}
MC/DC0%0/2
not $args->{"_t"} and $self->{"token"}
not $args->{"_t"}
$self->{"token"}
Truth table33%1/3
not(A) and B
A= not $args->{"_t"}B= $self->{"token"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 7 | ▶ | local $args->{'_c'} = do {my $i = my $c = 0; $c = [(caller $i++)[0..3]] while !$i || $c->[0]->isa(__PACKAGE__); join '; ', @$c} if ! $self->config(no_trace => undef, $name); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%3/3
not $i or $c->[0]->isa(__PACKAGE__)
MC/DC100%2/2
not $i or $c->[0]->isa(__PACKAGE__)
not $i
$c->[0]->isa(__PACKAGE__)
Truth table100%3/3
not(A) or B
A= not $iB= $c->[0]->isa(__PACKAGE__)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 7 | ▶ | local $self->{'flat'} = exists($args->{'_flat'}) ? delete($args->{'_flat'}) : $self->config(flat => undef, $name); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 7 | ▶ | return $self->_remote_call($method, $args) if $self->_needs_remote($method); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | return $self->_local_call( $method, $args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 14 | ▶ | sub _needs_remote { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_needs_remote: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 14 | my ($self, $method) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 14 | return $method !~ /(^local_|_local$)/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | ▶ | sub _local_call { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_local_call: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | my ($self, $method, $args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | my $name = $self->service_name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | ▶ | local $self->{'brand'} ||= $self->api_brand($name); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
local $self->{"brand"} ||= $self->api_brand($name)
MC/DC0%0/2
local $self->{"brand"} ||= $self->api_brand($name)
local $self->{"brand"}
$self->api_brand($name)
Truth table0%0/3
A ||= B
A= local $self->{"brand"}B= $self->api_brand($name)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | my $hash = eval { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | ▶ | my $code = $self->can("__$method") || throw "Invalid $name service method", {method => $method}, 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->can("__$method") || throw("Invalid $name service method", {'method', $method}, 1)
MC/DC0%0/2
$self->can("__$method") || throw("Invalid $name service method", {'method', $method}, 1)
$self->can("__$method")
throw("Invalid $name service method", {'method', $method}, 1)
Truth table0%0/3
A || B
A= $self->can("__$method")B= throw("Invalid $name service method", {'method', $method}, 1)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | ▶ | return $code->($self, $args); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $@ eq "HASH" and $@->{"error"}
MC/DC0%0/2
ref $@ eq "HASH" and $@->{"error"}
ref $@ eq "HASH"
$@->{"error"}
Truth table0%0/3
A and B
A= ref $@ eq "HASH"B= $@->{"error"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | ▶ | } || (ref($@) eq 'HASH' && $@->{'error'} ? $@ : {error => "Trouble running $name service method", service => $name}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
eval {
do {
my $code = $self->can("__$method") || throw("Invalid $name service method", {'method', $method}, 1);
return &$code($self, $args)
}
} || (ref $@ eq 'HASH' && $@->{'error'} ? $@ : {'error', "Trouble running $name service method", 'service', $name})
MC/DC0%0/2
eval {
do {
my $code = $self->can("__$method") || throw("Invalid $name service method", {'method', $method}, 1);
return &$code($self, $args)
}
} || (ref $@ eq 'HASH' && $@->{'error'} ? $@ : {'error', "Trouble running $name service method", 'service', $name})
eval {
do {
my $code = $self->can("__$method") || throw("Invalid $name service method", {'method', $method}, 1);
return &$code($self, $args)
}
}
(ref $@ eq 'HASH' && $@->{'error'} ? $@ : {'error', "Trouble running $name service method", 'service', $name})
Truth table0%0/3
A || B
A= eval {
do {
my $code = $self->can("__$method") || throw("Invalid $name service method", {'method', $method}, 1);
return &$code($self, $args)
}
}B= (ref $@ eq 'HASH' && $@->{'error'} ? $@ : {'error', "Trouble running $name service method", 'service', $name})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | return $self->_result({method => $method, args => $args, data => $hash, service => $name, url => 'local'}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 109 | ▶ | sub config { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
config: called CC=10 SCAR=28.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 109 | my ($self, $key, $def, $name) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 109 | ▶ | $name ||= $self->service_name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$name ||= $self->service_name
MC/DC0%0/2
$name ||= $self->service_name
$name
$self->service_name
Truth table33%1/3
A ||= B
A= $nameB= $self->service_name
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 109 | my $c = $self->_configs($name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | return exists($self->{$key}) ? $self->{$key} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | : exists($c->{"${name}_service_${key}"}) ? $c->{"${name}_service_${key}"} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | : (ref($c->{"${name}_service"}) && exists $c->{"${name}_service"}->{$key}) ? $c->{"${name}_service"}->{$key} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | : exists($c->{"${name}_${key}"}) ? $c->{"${name}_${key}"} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 109 | ▶ | : (ref($c->{$name}) && exists $c->{$name}->{$key}) ? $c->{$name}->{$key} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 6 branches
Condition33%2/6
ref $$c{"${name}_service"} and exists $$c{"${name}_service"}{$key}
ref $c->{$name} and exists $c->{$name}{$key}
MC/DC0%0/2
ref $$c{"${name}_service"} and exists $$c{"${name}_service"}{$key}
ref $$c{"${name}_service"}
exists $$c{"${name}_service"}{$key}
MC/DC0%0/2
ref $c->{$name} and exists $c->{$name}{$key}
ref $c->{$name}
exists $c->{$name}{$key}
Truth table33%1/3
A and B
A= ref $$c{"${name}_service"}B= exists $$c{"${name}_service"}{$key}
Truth table33%1/3
A and B
A= ref $c->{$name}B= exists $c->{$name}{$key}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | : ref($def) eq 'CODE' ? $def->($self) : $def; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 7 | ▶ | sub api_brand { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
api_brand: called CC=3 SCAR=17.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 7 | my ($self, $name) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 7 | ▶ | $name ||= $self->service_name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$name ||= $self->service_name
MC/DC0%0/2
$name ||= $self->service_name
$name
$self->service_name
Truth table33%1/3
A ||= B
A= $nameB= $self->service_name
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 7 | ▶ | return undef if $self->config(no_brand => undef, $name); ## no critic (ProhibitExplicitReturnUndef) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | ▶ | $self->config(brand => sub { eval { config::provider() } || $self->_configs->{'provider'} || do { warn "Missing $name brand"; '-' } }, $name); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=22.6
Branch: 1 branch
Condition0%0/3
eval {
do {
config::provider()
}
} or $self->_configs->{"provider"}
MC/DC0%0/2
eval {
do {
config::provider()
}
} or $self->_configs->{"provider"}
eval {
do {
config::provider()
}
}
$self->_configs->{"provider"}
Truth table0%0/3
A or B
A= eval {
do {
config::provider()
}
}B= $self->_configs->{"provider"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 7 | ▶ | sub _remote_call { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_remote_call: called CC=43 SCAR=49.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 7 | my ($self, $method, $args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 7 | my $begin = Time::HiRes::time(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 7 | my $name = $self->service_name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 7 | my $brand = $self->api_brand($name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 7 | ▶ | my $val = sub { my ($key, $def) = @_; $self->config($key, $def, $name) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 7 | my $no_ssl = $val->(no_ssl => undef); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | ▶ | my $host = $val->(host => sub {throw "Missing $name service host",undef,1}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 7 | ▶ | my $port = $val->(port => ($no_ssl ? 80 : 443)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 7 | ▶ | my $path = $val->(path => sub { $name =~ /^(\w+)_service/ ? $1 : $name }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.2
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 7 | ▶ | my $pass = $val->(no_sign => undef) ? undef : $val->(pass => undef); # rely on the server to tell us if a password is necessary | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 7 | ▶ | my $utf8 = exists($args->{'_utf8_encoded'}) ? delete($args->{'_utf8_encoded'}) : $val->(utf8_encoded => undef); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 7 | ▶ | my $enc = $utf8 && (!ref($utf8) || $utf8->{$method}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition16%1/6
$utf8 && (!ref($utf8) || $utf8->{$method})
not ref $utf8 or $utf8->{$method}
MC/DC0%0/3
$utf8 && (!ref($utf8) || $utf8->{$method})
$utf8
not ref $utf8
$utf8->{$method}
Truth table25%1/4
A && not(B) or C
A= $utf8B= not ref $utf8C= $utf8->{$method}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 7 | my $retry = $val->(retry => undef); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 7 | my $ns = $val->(ns => undef); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 7 | ▶ | $method = "${ns}_${method}" if $ns; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 7 | ▶ | my $url = "/$path/$method".($brand ? "/$brand" : ''); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 7 | my $cookie = $val->(cookie => undef); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 7 | my $req; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | ▶ | local $SIG{'ALRM'} = sub { die "Timeout on $name\n" }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 7 | ▶ | my $old = alarm($args->{'_timeout'} || $val->(timeout => 120)) || 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition40%2/5
alarm($args->{'_timeout'} || &$val('timeout', 120)) || 0
$args->{'_timeout'} || &$val('timeout', 120)
MC/DC0%0/2
alarm($args->{'_timeout'} || &$val('timeout', 120)) || 0
$args->{'_timeout'}
&$val('timeout', 120)
Truth table33%1/3
A || B
A= $args->{'_timeout'}B= &$val('timeout', 120)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 7 | my %head; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | my $hash = eval { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 7 | ▶ | _decode_utf8_recurse($args) if $enc; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 7 | ▶ | $req = eval { $self->json->encode($args) } || throw "Trouble encoding $name service json", {msg => $@}, 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
eval {
do {
$self->json->encode($args)
}
} || throw("Trouble encoding $name service json", {'msg', $@}, 1)
MC/DC0%0/2
eval {
do {
$self->json->encode($args)
}
} || throw("Trouble encoding $name service json", {'msg', $@}, 1)
eval {
do {
$self->json->encode($args)
}
}
throw("Trouble encoding $name service json", {'msg', $@}, 1)
Truth table33%1/3
A || B
A= eval {
do {
$self->json->encode($args)
}
}B= throw("Trouble encoding $name service json", {'msg', $@}, 1)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 7 | ▶ | my $sign = defined($pass) ? do { my $t = int $begin; "X-Respite-Auth: ".($val->('md5_pass') ? md5_hex($pass) : md5_hex("$pass:$t:$url:".md5_hex($req)).":$t")."\r\n" } : ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 7 | ▶ | $cookie = $cookie ? "Cookie: $cookie\r\n" : ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 7 | my $sock; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 7 | my $i = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 7 | ▶ | while (++$i) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | # Note SSL verify may not work as expected on IO::Socket::SSL versions below v1.46 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 7 | ▶ | $sock = $no_ssl ? IO::Socket::INET->new("$host:$port") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | : IO::Socket::SSL->new(PeerAddr => $host, PeerPort => $port, SSL_verify_mode => $val->(ssl_verify_mode => 0)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 7 | ▶ | last if $sock || !$retry || (Time::HiRes::time() - $begin > 3); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$sock or not $retry or &Time::HiRes::time() - $begin > 3
$sock or not $retry
MC/DC0%0/3
$sock or not $retry or &Time::HiRes::time() - $begin > 3
$sock
not $retry
&Time::HiRes::time() - $begin > 3
Truth table25%1/4
A or not(B) or C
A= $sockB= not $retryC= &Time::HiRes::time() - $begin > 3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | sleep 0.5; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 7 | ▶ | if (!$sock) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | ▶ | throw "Could not connect to $name service", { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
!$no_ssl && ($IO::Socket::SSL::SSL_ERROR || $!)
$IO::Socket::SSL::SSL_ERROR or $!
MC/DC0%0/3
!$no_ssl && ($IO::Socket::SSL::SSL_ERROR || $!)
!$no_ssl
$IO::Socket::SSL::SSL_ERROR
$!
Truth table0%0/4
not(A) && B or C
A= !$no_sslB= $IO::Socket::SSL::SSL_ERRORC= $!
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | host => $host, port => $port, url => $url, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | msg => (!$no_ssl && ($IO::Socket::SSL::SSL_ERROR || $!)), detail => "$@", ssl => !$no_ssl, tries => $i, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 7 | my $out = "POST $url HTTP/1.0\r\n${cookie}${sign}Host: $host\r\nContent-length: ".length($req)."\r\nContent-type: application/json\r\n\r\n$req"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 7 | ▶ | warn "DEBUG_Respite: Connected to http".($no_ssl?'':'s')."://$host:$port/\n$out\n" if $ENV{'DEBUG_Respite'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 7 | print $sock $out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 7 | my ($len, $type, $line); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 7 | ▶ | throw "Got non-200 status from $name service", {status => $line, url => $url} if !($line = <$sock>) || $line !~ m{^HTTP/\S+ 200\b}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$line = readline $sock and $line =~ m[^HTTP/\S+ 200\b]
MC/DC0%0/2
$line = readline $sock and $line =~ m[^HTTP/\S+ 200\b]
$line = readline $sock
$line =~ m[^HTTP/\S+ 200\b]
Truth table33%1/3
A and B
A= $line = readline $sockB= $line =~ m[^HTTP/\S+ 200\b]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 7 | ▶ | while (defined($line = <$sock>)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 42 | ▶ | $line =~ s/\r?\n$// || throw "Failed to find line termination", {line => $line}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 42 | ▶ | last if $line eq ""; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 35 | my ($key, $val) = split /\s*:\s*/, $line, 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | ▶ | $head{$key} = $head{$key} ? ref($head{$key}) ? [@{$head{$key}}, $val] : [$head{$key}, $val] : $val; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 35 | ▶ | $len = ($val =~ /^\d+$/) ? $val : throw "Invalid content length", {h => \%head} if lc($key) eq 'content-length'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 7 | ▶ | throw "Failed to find content length in $name service response" if ! $len; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 7 | ▶ | throw "Content too large in $name service", {length => $len} if $len > 100_000_000; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 7 | my $data = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 7 | while (1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 7 | ▶ | read($sock, $data, $len, length $data) || throw "Failed to read bytes", {needed => $len, got => length($data)}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 7 | ▶ | last if length $data >= $len; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 7 | close $sock; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 7 | alarm($old); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 7 | ▶ | throw "Invalid $name service json object string" if $data !~ /^\s*\{/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 7 | ▶ | my $resp = eval { $self->json->decode($data) } || throw "Failed to decode $name service json response data", {msg => $@}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
eval {
do {
$self->json->decode($data)
}
} || throw("Failed to decode $name service json response data", {'msg', $@})
MC/DC0%0/2
eval {
do {
$self->json->decode($data)
}
} || throw("Failed to decode $name service json response data", {'msg', $@})
eval {
do {
$self->json->decode($data)
}
}
throw("Failed to decode $name service json response data", {'msg', $@})
Truth table33%1/3
A || B
A= eval {
do {
$self->json->decode($data)
}
}B= throw("Failed to decode $name service json response data", {'msg', $@})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 7 | ▶ | _encode_utf8_recurse($resp) if $enc; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 7 | $resp; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | ▶ | } || do { alarm($old); {error => "Failed to get valid $name service response: $@"} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
eval {
do {
_decode_utf8_recurse($args) if $enc;
$req = eval {
do {
$self->json->encode($args)
}
} || throw("Trouble encoding $name service json", {'msg', $@}, 1);
my $sign = defined $pass ? do {
my $t = int $begin;
'X-Respite-Auth: ' . (&$val('md5_pass') ? md5_hex($pass) : md5_hex("${pass}:${t}:${url}:" . md5_hex($req)) . ":$t") . "\r\n"
} : '';
$cookie = $cookie ? "Cookie: $cookie\r\n" : '';
my $sock;
my $i = 0;
while (++$i) {
$sock = $no_ssl ? 'IO::Socket::INET'->new("${host}:$port") : 'IO::Socket::SSL'->new('PeerAddr', $host, 'PeerPort', $port, 'SSL_verify_mode', &$val('ssl_verify_mode', 0));
last if $sock or not $retry or &Time::HiRes::time() - $begin > 3;
&Net::Respite::Client::sleep(0.5);
};
unless ($sock) {
throw("Could not connect to $name service", {'host', $host, 'port', $port, 'url', $url, 'msg', !$no_ssl && ($IO::Socket::SSL::SSL_ERROR || $!), 'detail', "$@", 'ssl', !$no_ssl, 'tries', $i});
};
my $out = "POST $url HTTP/1.0\r\n$cookie${sign}Host: $host\r\nContent-length: " . length($req) . "\r\nContent-type: application/json\r\n\r\n$req";
warn 'DEBUG_Respite: Connected to http' . ($no_ssl ? '' : 's') . "://${host}:$port/\n$out\n" if $ENV{'DEBUG_Respite'};
print $sock $out;
my($len, $type, $line);
throw("Got non-200 status from $name service", {'status', $line, 'url', $url}) unless $line = readline $sock and $line =~ m[^HTTP/\S+ 200\b];
while (defined($line = readline $sock)) {
$line =~ s/\r?\n$// or throw('Failed to find line termination', {'line', $line});
last if $line eq '';
() = split(/\s*:\s*/, $line, 2);
$head{$key} = $head{$key} ? ref $head{$key} ? [@{$head{$key};}, $val] : [$head{$key}, $val] : $val;
$len = $val =~ /^\d+$/ ? $val : throw('Invalid content length', {'h', \%head}) if lc $key eq 'content-length';
};
throw("Failed to find content length in $name service response") unless $len;
throw("Content too large in $name service", {'length', $len}) if $len > 100000000;
my $data = '';
while (1) {
read $sock, $data, $len, length $data or throw('Failed to read bytes', {'needed', $len, 'got', length $data});
last if length $data >= $len;
};
close $sock;
alarm $old;
throw("Invalid $name service json object string") unless $data =~ /^\s*\{/;
my $resp = eval {
do {
$self->json->decode($data)
}
} || throw("Failed to decode $name service json response data", {'msg', $@});
_encode_utf8_recurse($resp) if $enc;
$resp
}
} || do {
alarm $old;
+{'error', "Failed to get valid $name service response: $@"}
}
MC/DC0%0/2
eval {
do {
_decode_utf8_recurse($args) if $enc;
$req = eval {
do {
$self->json->encode($args)
}
} || throw("Trouble encoding $name service json", {'msg', $@}, 1);
my $sign = defined $pass ? do {
my $t = int $begin;
'X-Respite-Auth: ' . (&$val('md5_pass') ? md5_hex($pass) : md5_hex("${pass}:${t}:${url}:" . md5_hex($req)) . ":$t") . "\r\n"
} : '';
$cookie = $cookie ? "Cookie: $cookie\r\n" : '';
my $sock;
my $i = 0;
while (++$i) {
$sock = $no_ssl ? 'IO::Socket::INET'->new("${host}:$port") : 'IO::Socket::SSL'->new('PeerAddr', $host, 'PeerPort', $port, 'SSL_verify_mode', &$val('ssl_verify_mode', 0));
last if $sock or not $retry or &Time::HiRes::time() - $begin > 3;
&Net::Respite::Client::sleep(0.5);
};
unless ($sock) {
throw("Could not connect to $name service", {'host', $host, 'port', $port, 'url', $url, 'msg', !$no_ssl && ($IO::Socket::SSL::SSL_ERROR || $!), 'detail', "$@", 'ssl', !$no_ssl, 'tries', $i});
};
my $out = "POST $url HTTP/1.0\r\n$cookie${sign}Host: $host\r\nContent-length: " . length($req) . "\r\nContent-type: application/json\r\n\r\n$req";
warn 'DEBUG_Respite: Connected to http' . ($no_ssl ? '' : 's') . "://${host}:$port/\n$out\n" if $ENV{'DEBUG_Respite'};
print $sock $out;
my($len, $type, $line);
throw("Got non-200 status from $name service", {'status', $line, 'url', $url}) unless $line = readline $sock and $line =~ m[^HTTP/\S+ 200\b];
while (defined($line = readline $sock)) {
$line =~ s/\r?\n$// or throw('Failed to find line termination', {'line', $line});
last if $line eq '';
() = split(/\s*:\s*/, $line, 2);
$head{$key} = $head{$key} ? ref $head{$key} ? [@{$head{$key};}, $val] : [$head{$key}, $val] : $val;
$len = $val =~ /^\d+$/ ? $val : throw('Invalid content length', {'h', \%head}) if lc $key eq 'content-length';
};
throw("Failed to find content length in $name service response") unless $len;
throw("Content too large in $name service", {'length', $len}) if $len > 100000000;
my $data = '';
while (1) {
read $sock, $data, $len, length $data or throw('Failed to read bytes', {'needed', $len, 'got', length $data});
last if length $data >= $len;
};
close $sock;
alarm $old;
throw("Invalid $name service json object string") unless $data =~ /^\s*\{/;
my $resp = eval {
do {
$self->json->decode($data)
}
} || throw("Failed to decode $name service json response data", {'msg', $@});
_encode_utf8_recurse($resp) if $enc;
$resp
}
} || do {
alarm $old;
+{'error', "Failed to get valid $name service response: $@"}
}
eval {
do {
_decode_utf8_recurse($args) if $enc;
$req = eval {
do {
$self->json->encode($args)
}
} || throw("Trouble encoding $name service json", {'msg', $@}, 1);
my $sign = defined $pass ? do {
my $t = int $begin;
'X-Respite-Auth: ' . (&$val('md5_pass') ? md5_hex($pass) : md5_hex("${pass}:${t}:${url}:" . md5_hex($req)) . ":$t") . "\r\n"
} : '';
$cookie = $cookie ? "Cookie: $cookie\r\n" : '';
my $sock;
my $i = 0;
while (++$i) {
$sock = $no_ssl ? 'IO::Socket::INET'->new("${host}:$port") : 'IO::Socket::SSL'->new('PeerAddr', $host, 'PeerPort', $port, 'SSL_verify_mode', &$val('ssl_verify_mode', 0));
last if $sock or not $retry or &Time::HiRes::time() - $begin > 3;
&Net::Respite::Client::sleep(0.5);
};
unless ($sock) {
throw("Could not connect to $name service", {'host', $host, 'port', $port, 'url', $url, 'msg', !$no_ssl && ($IO::Socket::SSL::SSL_ERROR || $!), 'detail', "$@", 'ssl', !$no_ssl, 'tries', $i});
};
my $out = "POST $url HTTP/1.0\r\n$cookie${sign}Host: $host\r\nContent-length: " . length($req) . "\r\nContent-type: application/json\r\n\r\n$req";
warn 'DEBUG_Respite: Connected to http' . ($no_ssl ? '' : 's') . "://${host}:$port/\n$out\n" if $ENV{'DEBUG_Respite'};
print $sock $out;
my($len, $type, $line);
throw("Got non-200 status from $name service", {'status', $line, 'url', $url}) unless $line = readline $sock and $line =~ m[^HTTP/\S+ 200\b];
while (defined($line = readline $sock)) {
$line =~ s/\r?\n$// or throw('Failed to find line termination', {'line', $line});
last if $line eq '';
() = split(/\s*:\s*/, $line, 2);
$head{$key} = $head{$key} ? ref $head{$key} ? [@{$head{$key};}, $val] : [$head{$key}, $val] : $val;
$len = $val =~ /^\d+$/ ? $val : throw('Invalid content length', {'h', \%head}) if lc $key eq 'content-length';
};
throw("Failed to find content length in $name service response") unless $len;
throw("Content too large in $name service", {'length', $len}) if $len > 100000000;
my $data = '';
while (1) {
read $sock, $data, $len, length $data or throw('Failed to read bytes', {'needed', $len, 'got', length $data});
last if length $data >= $len;
};
close $sock;
alarm $old;
throw("Invalid $name service json object string") unless $data =~ /^\s*\{/;
my $resp = eval {
do {
$self->json->decode($data)
}
} || throw("Failed to decode $name service json response data", {'msg', $@});
_encode_utf8_recurse($resp) if $enc;
$resp
}
}
do {
alarm $old;
+{'error', "Failed to get valid $name service response: $@"}
}
Truth table33%1/3
A || B
A= eval {
do {
_decode_utf8_recurse($args) if $enc;
$req = eval {
do {
$self->json->encode($args)
}
} || throw("Trouble encoding $name service json", {'msg', $@}, 1);
my $sign = defined $pass ? do {
my $t = int $begin;
'X-Respite-Auth: ' . (&$val('md5_pass') ? md5_hex($pass) : md5_hex("${pass}:${t}:${url}:" . md5_hex($req)) . ":$t") . "\r\n"
} : '';
$cookie = $cookie ? "Cookie: $cookie\r\n" : '';
my $sock;
my $i = 0;
while (++$i) {
$sock = $no_ssl ? 'IO::Socket::INET'->new("${host}:$port") : 'IO::Socket::SSL'->new('PeerAddr', $host, 'PeerPort', $port, 'SSL_verify_mode', &$val('ssl_verify_mode', 0));
last if $sock or not $retry or &Time::HiRes::time() - $begin > 3;
&Net::Respite::Client::sleep(0.5);
};
unless ($sock) {
throw("Could not connect to $name service", {'host', $host, 'port', $port, 'url', $url, 'msg', !$no_ssl && ($IO::Socket::SSL::SSL_ERROR || $!), 'detail', "$@", 'ssl', !$no_ssl, 'tries', $i});
};
my $out = "POST $url HTTP/1.0\r\n$cookie${sign}Host: $host\r\nContent-length: " . length($req) . "\r\nContent-type: application/json\r\n\r\n$req";
warn 'DEBUG_Respite: Connected to http' . ($no_ssl ? '' : 's') . "://${host}:$port/\n$out\n" if $ENV{'DEBUG_Respite'};
print $sock $out;
my($len, $type, $line);
throw("Got non-200 status from $name service", {'status', $line, 'url', $url}) unless $line = readline $sock and $line =~ m[^HTTP/\S+ 200\b];
while (defined($line = readline $sock)) {
$line =~ s/\r?\n$// or throw('Failed to find line termination', {'line', $line});
last if $line eq '';
() = split(/\s*:\s*/, $line, 2);
$head{$key} = $head{$key} ? ref $head{$key} ? [@{$head{$key};}, $val] : [$head{$key}, $val] : $val;
$len = $val =~ /^\d+$/ ? $val : throw('Invalid content length', {'h', \%head}) if lc $key eq 'content-length';
};
throw("Failed to find content length in $name service response") unless $len;
throw("Content too large in $name service", {'length', $len}) if $len > 100000000;
my $data = '';
while (1) {
read $sock, $data, $len, length $data or throw('Failed to read bytes', {'needed', $len, 'got', length $data});
last if length $data >= $len;
};
close $sock;
alarm $old;
throw("Invalid $name service json object string") unless $data =~ /^\s*\{/;
my $resp = eval {
do {
$self->json->decode($data)
}
} || throw("Failed to decode $name service json response data", {'msg', $@});
_encode_utf8_recurse($resp) if $enc;
$resp
}
}B= do {
alarm $old;
+{'error', "Failed to get valid $name service response: $@"}
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | return $self->_result({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | service => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | method => $method, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | args => $args, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | data => $hash, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | headers => \%head, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | url => $url, host => $host, port => $port, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | brand => $brand, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | elapsed => sprintf('%.05f', Time::HiRes::time() - $begin), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 7 | ▶ | ($self->{'pretty'} ? (pretty => 1) : ()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 7 | ▶ | sub _result { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_result: called CC=5 SCAR=17.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 7 | my ($self, $args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 7 | ▶ | if ($self->{'flat'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 7 | my $data = $args->{'data'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 7 | ▶ | throw {_service => $args->{'service'} || $self->service_name, %$data, ($args->{'pretty'} ? (_pretty => 1) : ())} if $data->{'error'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
$args->{'service'} || $self->service_name
MC/DC0%0/2
$args->{'service'} || $self->service_name
$args->{'service'}
$self->service_name
Truth table33%1/3
A || B
A= $args->{'service'}B= $self->service_name
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 5 | return $data; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | return bless $args, $self->_result_class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | ▶ | sub _result_class { shift->{'result_class'} || 'Net::Respite::Client::Result' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_result_class: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | ▶ | sub _encode_utf8_recurse { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_encode_utf8_recurse: not called CC=11 SCAR=48.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | my $d = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | ▶ | if (UNIVERSAL::isa($d, 'HASH')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | ▶ | for my $k (keys %$d) { my $v = $d->{$k}; (ref $v) ? _encode_utf8_recurse($v) : $v and utf8::is_utf8($v) and utf8::encode($d->{$k}) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
ref $v ? _encode_utf8_recurse($v) : $v and utf8::is_utf8($v)
MC/DC0%0/2
ref $v ? _encode_utf8_recurse($v) : $v and utf8::is_utf8($v)
ref $v ? _encode_utf8_recurse($v) : $v
utf8::is_utf8($v)
Truth table0%0/3
A and B
A= ref $v ? _encode_utf8_recurse($v) : $vB= utf8::is_utf8($v)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | } elsif (UNIVERSAL::isa($d, 'ARRAY')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | ▶ | for my $v (@$d) { (ref $v) ? _encode_utf8_recurse($v) : $v and utf8::is_utf8($v) and utf8::encode($v) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
ref $v ? _encode_utf8_recurse($v) : $v and utf8::is_utf8($v)
MC/DC0%0/2
ref $v ? _encode_utf8_recurse($v) : $v and utf8::is_utf8($v)
ref $v ? _encode_utf8_recurse($v) : $v
utf8::is_utf8($v)
Truth table0%0/3
A and B
A= ref $v ? _encode_utf8_recurse($v) : $vB= utf8::is_utf8($v)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | ▶ | sub _decode_utf8_recurse { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_decode_utf8_recurse: not called CC=13 SCAR=52.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | my $d = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | ▶ | my $seen = shift || {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || {}
MC/DC0%0/1
shift() || {}
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | ▶ | return if $seen->{$d}++; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | ▶ | if (UNIVERSAL::isa($d, 'HASH')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | ▶ | for my $k (keys %$d) { my $v = $d->{$k}; (ref $v) ? _decode_utf8_recurse($v, $seen) : $v and !utf8::is_utf8($v) and utf8::decode($d->{$k}) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
ref $v ? _decode_utf8_recurse($v, $seen) : $v and not utf8::is_utf8($v)
MC/DC0%0/2
ref $v ? _decode_utf8_recurse($v, $seen) : $v and not utf8::is_utf8($v)
ref $v ? _decode_utf8_recurse($v, $seen) : $v
not utf8::is_utf8($v)
Truth table0%0/3
A and not(B)
A= ref $v ? _decode_utf8_recurse($v, $seen) : $vB= not utf8::is_utf8($v)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | } elsif (UNIVERSAL::isa($d, 'ARRAY')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | ▶ | for my $v (@$d) { (ref $v) ? _decode_utf8_recurse($v, $seen) : $v and !utf8::is_utf8($v) and utf8::decode($v) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
ref $v ? _decode_utf8_recurse($v, $seen) : $v and not utf8::is_utf8($v)
MC/DC0%0/2
ref $v ? _decode_utf8_recurse($v, $seen) : $v and not utf8::is_utf8($v)
ref $v ? _decode_utf8_recurse($v, $seen) : $v
not utf8::is_utf8($v)
Truth table0%0/3
A and not(B)
A= ref $v ? _decode_utf8_recurse($v, $seen) : $vB= not utf8::is_utf8($v)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 7 | ▶ | sub AUTOLOAD { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
AUTOLOAD: called CC=7 SCAR=21.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 7 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 7 | ▶ | my $args = shift || {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift() || {}
MC/DC0%0/1
shift() || {}
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 7 | ▶ | my $meth = $Net::Respite::Client::AUTOLOAD =~ /::(\w+)$/ ? $1 : throw "Invalid method\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 7 | ▶ | throw "Self was not passed while looking up method", {method => $meth, trace => 1} if ! ref $self; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 7 | ▶ | throw "Invalid ".$self->service_name." method \"$meth\"", {trace => 1} if !$self->_needs_remote($meth) && ! $self->can("__${meth}"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->_needs_remote($meth) or $self->can("__$meth")
MC/DC0%0/2
$self->_needs_remote($meth) or $self->can("__$meth")
$self->_needs_remote($meth)
$self->can("__$meth")
Truth table33%1/3
A or B
A= $self->_needs_remote($meth)B= $self->can("__$meth")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 7 | ▶ | my $code = sub { $_[0]->run_method($meth => $_[1]) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 4 | ▶ | no strict 'refs'; ## no critic | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | ▶ | *{ref($self)."::$meth"} = $code if __PACKAGE__ ne ref($self); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 7 | return $self->$code($args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | ▶ | sub DESTROY {} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | ▶ | sub run_commandline { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run_commandline: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | ▶ | my $args = ref($_[0]) ? shift : {@_}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | ▶ | my $self = ref($class) ? $class : $class->new({%$args}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | require Net::Respite::CommandLine; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | ▶ | Net::Respite::CommandLine->run({dispatch_factory => sub { $self }}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | ###----------------------------------------------------------------### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | package Net::Respite::Client::Result; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | ▶ | use overload 'bool' => sub { ! shift->error }, '""' => \&as_string, fallback => 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.2
Subroutine
__ANON__: not called CC=1 SCAR=0.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | ▶ | sub error { shift->data->{'error'} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
error: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | ▶ | sub TO_JSON { return {%{$_[0]}} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
TO_JSON: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | ▶ | sub as_string { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_string: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | ▶ | if (my $err = $self->error) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | my $data = $self->data; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | ▶ | my $p = defined($Net::Respite::Client::pretty) ? $Net::Respite::Client::pretty : $self->{'pretty'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | local $data->{'error'}; delete $data->{'error'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | ▶ | return !scalar keys %$self ? $err : "$err: ".($p ? Net::Respite::Client::jsop():Net::Respite::Client::json())->encode({%$data}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | return "Called $self->{'service'} service method $self->{'method'}"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | ▶ | sub data { shift->{'data'} ||= {} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
data: not called CC=2 SCAR=17.9
Condition0%0/2
+(shift())->{"data"} ||= {}
MC/DC0%0/1
+(shift())->{"data"} ||= {}
+(shift())->{"data"}
Truth table0%0/2
A
A= +(shift())->{"data"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 4 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||