| 1 | package Net::Respite::Server; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | # Net::Respite::Server - generic Respite based Respite server | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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 | our @ISA; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 4 | ▶ | use base 'Net::Respite::Common'; # Default _configs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 4 | ▶ | use Digest::MD5 qw(md5_hex); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 4 | ▶ | use Throw qw(throw); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 4 | ▶ | use Time::HiRes qw(sleep); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 18 | ▶ | sub server_name { $_[0]->{'server_name'} ||= ($0 =~ m|/(\w+)$|x) ? $1 : throw 'Missing server_name' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
server_name: called CC=3 SCAR=17.3
Pod
documented
Branch: 1 branch
Condition33%1/3
$_[0]{"server_name"} ||= $0 =~ m[/(\w+)$]x ? $1 : throw("Missing server_name")
MC/DC0%0/2
$_[0]{"server_name"} ||= $0 =~ m[/(\w+)$]x ? $1 : throw("Missing server_name")
$_[0]{"server_name"}
$0 =~ m[/(\w+)$]x ? $1 : throw("Missing server_name")
Truth table33%1/3
A ||= B
A= $_[0]{"server_name"}B= $0 =~ m[/(\w+)$]x ? $1 : throw("Missing server_name")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 0 | ▶ | sub revision { $_[0]->{'revision'} ||= eval { $_[0]->dispatch_class->_revision } || '-' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
revision: not called CC=3 SCAR=24.8
Pod
undocumented
Condition0%0/5
$_[0]{"revision"} ||= eval {
do {
$_[0]->dispatch_class->_revision
}
} || "-"
eval {
do {
$_[0]->dispatch_class->_revision
}
} || '-'
MC/DC0%0/2
$_[0]{"revision"} ||= eval {
do {
$_[0]->dispatch_class->_revision
}
} || "-"
$_[0]{"revision"}
eval {
do {
$_[0]->dispatch_class->_revision
}
}
Truth table0%0/3
A ||= B
A= $_[0]{"revision"}B= eval {
do {
$_[0]->dispatch_class->_revision
}
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 0 | ▶ | sub max_request_size { $_[0]->{'max_request_size'} || 2_000_000 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
max_request_size: not called CC=2 SCAR=17.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 5 | ▶ | sub api_meta { shift->{'api_meta'} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
api_meta: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 0 | ▶ | sub dispatch_class { shift->{'dispatch_class'} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dispatch_class: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | ###----------------------------------------------------------------### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 5 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=9 SCAR=23.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 5 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 5 | ▶ | my $self = bless ref($_[0]) ? shift : {@_}, $class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 5 | ▶ | %$self = (%$_, %$self) if $_ = $self->new_args; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 5 | ▶ | return $self if $self->{'non_daemon'} || ($ENV{'MOD_PERL'} && ! $self->{'force_daemon'}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$self->{"non_daemon"} or $ENV{"MOD_PERL"} and not $self->{"force_daemon"}
$ENV{"MOD_PERL"} and not $self->{"force_daemon"}
MC/DC0%0/3
$self->{"non_daemon"} or $ENV{"MOD_PERL"} and not $self->{"force_daemon"}
$self->{"non_daemon"}
$ENV{"MOD_PERL"}
not $self->{"force_daemon"}
Truth table25%1/4
A or B and not(C)
A= $self->{"non_daemon"}B= $ENV{"MOD_PERL"}C= not $self->{"force_daemon"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 5 | require Net::Server; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 5 | require Net::Server::HTTP; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 5 | ▶ | unshift @ISA, qw(Net::Server::HTTP) if !$self->isa(qw(Net::Server::HTTP));; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 5 | ▶ | throw 'We need a more recent Net::Server revision', {v => $Net::Server::VERSION} if $Net::Server::VERSION < 2.007; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 5 | $self->json; # vivify before fork | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 5 | my $server = $class->SUPER::new(%$self, %{ $self->server_args }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 5 | @$server{keys %$self} = values %$self; # TODO - avoid duplicates | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 5 | ▶ | $self->dispatch_factory('preload') if !$ENV{'NO_PRELOAD'}; # void call will load necessary classes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 5 | return $server; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 5 | ▶ | sub new_args {} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new_args: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 60 | ▶ | sub config { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
config: called CC=7 SCAR=22.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 60 | my ($self, $key, $def, $name) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 60 | ▶ | $name ||= $self->server_name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$name ||= $self->server_name
MC/DC0%0/2
$name ||= $self->server_name
$name
$self->server_name
Truth table33%1/3
A ||= B
A= $nameB= $self->server_name
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 60 | my $c = $self->_configs($name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | return exists($self->{$key}) ? $self->{$key} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | : exists($c->{"${name}_${key}"}) ? $c->{"${name}_${key}"} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 60 | ▶ | : (ref($c->{$name}) && exists $c->{$name}->{$key}) ? $c->{$name}->{$key} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
Condition33%1/3
ref $c->{$name} and exists $c->{$name}{$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}B= exists $c->{$name}{$key}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | : ref($def) eq 'CODE' ? $def->($self) : $def; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 5 | ▶ | sub dispatch_factory { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dispatch_factory: called CC=9 SCAR=31.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 5 | my ($self, $preload) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 5 | ▶ | return $self->{'dispatch_factory'} ||= do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$self->{"dispatch_factory"} ||= do {
my $meta = $self->api_meta || $self->dispatch_class || throw("Missing one of api_meta or dispatch_class");
if (not ref $meta) {
(my $file = "$meta.pm") =~ s[::][/]g;
throw("Failed to load dispatch class", {"class", $meta, "file", $file, "msg", $@}) unless $meta->can("new") or eval {
do {
require $file
}
};
throw("Specified class does not have a run_method method", {"class", $meta}) unless $meta->can("run_method");
sub {
$meta->new(@_);
}
;
}
else {
require Net::Respite::Base;
"Net::Respite::Base"->new({"api_meta", $meta})->api_preload if $preload;
sub {
"Net::Respite::Base"->new({%{shift();}, "api_meta", $meta});
}
;
}
}
MC/DC0%0/2
$self->{"dispatch_factory"} ||= do {
my $meta = $self->api_meta || $self->dispatch_class || throw("Missing one of api_meta or dispatch_class");
if (not ref $meta) {
(my $file = "$meta.pm") =~ s[::][/]g;
throw("Failed to load dispatch class", {"class", $meta, "file", $file, "msg", $@}) unless $meta->can("new") or eval {
do {
require $file
}
};
throw("Specified class does not have a run_method method", {"class", $meta}) unless $meta->can("run_method");
sub {
$meta->new(@_);
}
;
}
else {
require Net::Respite::Base;
"Net::Respite::Base"->new({"api_meta", $meta})->api_preload if $preload;
sub {
"Net::Respite::Base"->new({%{shift();}, "api_meta", $meta});
}
;
}
}
$self->{"dispatch_factory"}
do {
my $meta = $self->api_meta || $self->dispatch_class || throw("Missing one of api_meta or dispatch_class");
if (not ref $meta) {
(my $file = "$meta.pm") =~ s[::][/]g;
throw("Failed to load dispatch class", {"class", $meta, "file", $file, "msg", $@}) unless $meta->can("new") or eval {
do {
require $file
}
};
throw("Specified class does not have a run_method method", {"class", $meta}) unless $meta->can("run_method");
sub {
$meta->new(@_);
}
;
}
else {
require Net::Respite::Base;
"Net::Respite::Base"->new({"api_meta", $meta})->api_preload if $preload;
sub {
"Net::Respite::Base"->new({%{shift();}, "api_meta", $meta});
}
;
}
}
Truth table33%1/3
A ||= B
A= $self->{"dispatch_factory"}B= do {
my $meta = $self->api_meta || $self->dispatch_class || throw("Missing one of api_meta or dispatch_class");
if (not ref $meta) {
(my $file = "$meta.pm") =~ s[::][/]g;
throw("Failed to load dispatch class", {"class", $meta, "file", $file, "msg", $@}) unless $meta->can("new") or eval {
do {
require $file
}
};
throw("Specified class does not have a run_method method", {"class", $meta}) unless $meta->can("run_method");
sub {
$meta->new(@_);
}
;
}
else {
require Net::Respite::Base;
"Net::Respite::Base"->new({"api_meta", $meta})->api_preload if $preload;
sub {
"Net::Respite::Base"->new({%{shift();}, "api_meta", $meta});
}
;
}
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 5 | ▶ | my $meta = $self->api_meta || $self->dispatch_class || throw "Missing one of api_meta or dispatch_class"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%2/6
$self->api_meta || $self->dispatch_class || throw('Missing one of api_meta or dispatch_class')
$self->api_meta or $self->dispatch_class
MC/DC0%0/3
$self->api_meta || $self->dispatch_class || throw('Missing one of api_meta or dispatch_class')
$self->api_meta
$self->dispatch_class
throw('Missing one of api_meta or dispatch_class')
Truth table25%1/4
A or B || C
A= $self->api_metaB= $self->dispatch_classC= throw('Missing one of api_meta or dispatch_class')
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 5 | ▶ | if (!ref $meta) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 5 | (my $file = "$meta.pm") =~ s|::|/|g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | ▶ | throw "Failed to load dispatch class", {class => $meta, file => $file, msg => $@} if !$meta->can('new') && !eval { require $file }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$meta->can("new") or eval {
do {
require $file
}
}
MC/DC0%0/2
$meta->can("new") or eval {
do {
require $file
}
}
$meta->can("new")
eval {
do {
require $file
}
}
Truth table33%1/3
A or B
A= $meta->can("new")B= eval {
do {
require $file
}
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 5 | ▶ | throw "Specified class does not have a run_method method", {class => $meta} if ! $meta->can('run_method'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | ▶ | sub { $meta->new(@_) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | require Net::Respite::Base; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | ▶ | Net::Respite::Base->new({api_meta => $meta})->api_preload if $preload; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | ▶ | sub { Net::Respite::Base->new({%{shift()}, api_meta => $meta}) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | ###----------------------------------------------------------------### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | # request handling and method dispatching | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | # mod_perl handler - used via apache conf | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | # <Location /foo/> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | # SetHandler modperl | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | # PerlResponseHandler FooServer | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | # </Location> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | # sub handler { __PACKAGE__->modperlhandler(@_) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | ▶ | sub modperlhandler { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
modperlhandler: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | ▶ | my $r = shift || throw "Missing apache request during ${class}::modperlhandler", {trace => 1}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
shift() || throw("Missing apache request during ${class}::modperlhandler", {'trace', 1})
MC/DC0%0/2
shift() || throw("Missing apache request during ${class}::modperlhandler", {'trace', 1})
shift()
throw("Missing apache request during ${class}::modperlhandler", {'trace', 1})
Truth table0%0/3
A || B
A= shift()B= throw("Missing apache request during ${class}::modperlhandler", {'trace', 1})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | my $self = $class->new({apache_req => $r, non_daemon => 1}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | my %env = %ENV; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | ▶ | if (eval { $self->modperl_init($r); $r->subprocess_env(); 1 }) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | $self->cgihandler(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | warn my $err = $self->json->encode({error => "$@", type => 'mod_perl_header'}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | $self->send_response($err); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | %ENV = %env; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | return 0; # OK - TODO - we actually may want a 403 for digest errors | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 4 | my $modperl_init; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | ▶ | sub modperl_init { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
modperl_init: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | ▶ | return if $modperl_init; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | $modperl_init = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | require Apache2::RequestRec; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | require Apache2::RequestIO; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | require APR::Table; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | # normal cgi-bin or Net::Server::HTTP handler | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | # Net::Server::HTTP app => \&cgihandler | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | # cgi-bin/server App::cgihandler() or App->new->cgihandler or App->cgihandler | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | ▶ | sub cgihandler { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cgihandler: not called CC=41 SCAR=74.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | ▶ | $self = ($self || __PACKAGE__)->new({%{shift() || {}}, non_daemon => 1}) if ! $self || ! ref($self); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/7
$self and ref $self
$self || __PACKAGE__
shift() || {}
MC/DC0%0/2
$self and ref $self
$self
ref $self
MC/DC0%0/1
$self || __PACKAGE__
$self
MC/DC0%0/1
shift() || {}
shift()
Truth table0%0/3
A and B
A= $selfB= ref $self
Truth table0%0/2
A
A= $self
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | local $self->{'transport'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | local $self->{'extra_headers'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | local $self->{'cgi_obj'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | my $req_sum; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | my $args = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | my $r = $self->{'apache_req'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | my $req; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | ▶ | if ($ENV{'CONTENT_TYPE'} && $ENV{'CONTENT_TYPE'} =~ /\bjson\b/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$ENV{"CONTENT_TYPE"} and $ENV{"CONTENT_TYPE"} =~ /\bjson\b/
MC/DC0%0/2
$ENV{"CONTENT_TYPE"} and $ENV{"CONTENT_TYPE"} =~ /\bjson\b/
$ENV{"CONTENT_TYPE"}
$ENV{"CONTENT_TYPE"} =~ /\bjson\b/
Truth table0%0/3
A and B
A= $ENV{"CONTENT_TYPE"}B= $ENV{"CONTENT_TYPE"} =~ /\bjson\b/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | ▶ | throw 'JSON data may not be submitted via GET' if !$ENV{'REQUEST_METHOD'} || $ENV{'REQUEST_METHOD'} eq 'GET' || $ENV{'REQUEST_METHOD'} eq 'HEAD'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
not $ENV{"REQUEST_METHOD"} or $ENV{"REQUEST_METHOD"} eq "GET" or $ENV{"REQUEST_METHOD"} eq "HEAD"
not $ENV{"REQUEST_METHOD"} or $ENV{"REQUEST_METHOD"} eq "GET"
MC/DC0%0/3
not $ENV{"REQUEST_METHOD"} or $ENV{"REQUEST_METHOD"} eq "GET" or $ENV{"REQUEST_METHOD"} eq "HEAD"
not $ENV{"REQUEST_METHOD"}
$ENV{"REQUEST_METHOD"} eq "GET"
$ENV{"REQUEST_METHOD"} eq "HEAD"
Truth table0%0/4
not(A) or B or C
A= not $ENV{"REQUEST_METHOD"}B= $ENV{"REQUEST_METHOD"} eq "GET"C= $ENV{"REQUEST_METHOD"} eq "HEAD"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | ▶ | my $len = $ENV{'CONTENT_LENGTH'} || throw "Missing CONTENT_LENGTH on $ENV{'REQUEST_METHOD'} request", {len => $ENV{'CONTENT_LENGTH'}}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$ENV{'CONTENT_LENGTH'} || throw("Missing CONTENT_LENGTH on $ENV{'REQUEST_METHOD'} request", {'len', $ENV{'CONTENT_LENGTH'}})
MC/DC0%0/2
$ENV{'CONTENT_LENGTH'} || throw("Missing CONTENT_LENGTH on $ENV{'REQUEST_METHOD'} request", {'len', $ENV{'CONTENT_LENGTH'}})
$ENV{'CONTENT_LENGTH'}
throw("Missing CONTENT_LENGTH on $ENV{'REQUEST_METHOD'} request", {'len', $ENV{'CONTENT_LENGTH'}})
Truth table0%0/3
A || B
A= $ENV{'CONTENT_LENGTH'}B= throw("Missing CONTENT_LENGTH on $ENV{'REQUEST_METHOD'} request", {'len', $ENV{'CONTENT_LENGTH'}})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | ▶ | throw "Too large a $ENV{'REQUEST_METHOD'} request found", {length => $len, max => $self->max_request_size} if $len > $self->max_request_size; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | my $size = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | while (1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | ▶ | $r ? $r->read($req, $len - $size, $size) : read(STDIN, $req, $len - $size, $size); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | ▶ | throw "Failed to read bytes", {needed => $len, got => $size} if length($req) == $size; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | ▶ | last if ($size = length $req) >= $len; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | ▶ | throw "Failed to read entire $ENV{'REQUEST_METHOD'} request", {length => $len, actual => length($req)} if length($req) != $len; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | my $args = $self->parse_form($r); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | $req = delete $args->{'POSTDATA'}; # CGI.pm - non-form POST | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | ▶ | if (!$req) { # get | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | $self->{'transport'} = 'form'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | ▶ | $args = Data::URIEncode::flat_to_complex($args) || {} if !$self->{'no_data_uriencode'} && (eval { require Data::URIEncode } || ((grep {$_ =~ /[:.]/} keys %$args) && throw "Failed to load Data::URIEncode", {msg => $@})); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/11
not $self->{"no_data_uriencode"} and eval {
do {
require Data::URIEncode
}
} || grep({$_ =~ /[:.]/;} keys %$args) && throw("Failed to load Data::URIEncode", {"msg", $@})
eval {
do {
require Data::URIEncode
}
} or grep {$_ =~ /[:.]/;} keys %$args and throw("Failed to load Data::URIEncode", {"msg", $@})
grep {$_ =~ /[:.]/;} keys %$args and throw("Failed to load Data::URIEncode", {"msg", $@})
Data::URIEncode::flat_to_complex($args) || {}
MC/DC0%0/4
not $self->{"no_data_uriencode"} and eval {
do {
require Data::URIEncode
}
} || grep({$_ =~ /[:.]/;} keys %$args) && throw("Failed to load Data::URIEncode", {"msg", $@})
not $self->{"no_data_uriencode"}
eval {
do {
require Data::URIEncode
}
}
grep {$_ =~ /[:.]/;} keys %$args
throw("Failed to load Data::URIEncode", {"msg", $@})
MC/DC0%0/1
Data::URIEncode::flat_to_complex($args) || {}
Data::URIEncode::flat_to_complex($args)
Truth table0%0/5
not(A) and B or C and D
A= not $self->{"no_data_uriencode"}B= eval {
do {
require Data::URIEncode
}
}C= grep {$_ =~ /[:.]/;} keys %$argsD= throw("Failed to load Data::URIEncode", {"msg", $@})
Truth table0%0/2
A
A= Data::URIEncode::flat_to_complex($args)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | return $args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | ▶ | throw "Found other args in addition to POSTDATA", {args => $args} if scalar keys %$args; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | $self->{'transport'} = 'json'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | ▶ | throw "Content data did not look like JSON hash", {head => substr($req, 0, 10)."...", content_type => $ENV{'CONTENT_TYPE'}} if $req !~ /^\{/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | $req_sum = md5_hex($req); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | return eval { $self->json->decode($req) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | ▶ | || throw 'Trouble unencoding json', {ip => $ENV{'REMOTE_ADDR'}, msg => $@, head => substr($req, 0, 10)."..."}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
eval {
do {
$self->json->decode($req)
}
} || throw('Trouble unencoding json', {'ip', $ENV{'REMOTE_ADDR'}, 'msg', $@, 'head', substr($req, 0, 10) . '...'})
MC/DC0%0/2
eval {
do {
$self->json->decode($req)
}
} || throw('Trouble unencoding json', {'ip', $ENV{'REMOTE_ADDR'}, 'msg', $@, 'head', substr($req, 0, 10) . '...'})
eval {
do {
$self->json->decode($req)
}
}
throw('Trouble unencoding json', {'ip', $ENV{'REMOTE_ADDR'}, 'msg', $@, 'head', substr($req, 0, 10) . '...'})
Truth table0%0/3
A || B
A= eval {
do {
$self->json->decode($req)
}
}B= throw('Trouble unencoding json', {'ip', $ENV{'REMOTE_ADDR'}, 'msg', $@, 'head', substr($req, 0, 10) . '...'})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | ▶ | if (! $args) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | my $err = $self->json->encode({error => "$@", type => 'cgihandler'}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | warn $err; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | return $self->send_response($err); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | ▶ | $ENV{'PATH_INFO'} ||= ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$ENV{"PATH_INFO"} ||= ""
MC/DC0%0/1
$ENV{"PATH_INFO"} ||= ""
$ENV{"PATH_INFO"}
Truth table0%0/2
A
A= $ENV{"PATH_INFO"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | ▶ | my ($old_out, $out_ref) = $self->{'warn_on_stdout'} ? do { open my $fh, ">", \(my $str =""); (select($fh), \$str) } : (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | local $self->{'_warn_info'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | my $ref = eval { $self->_do_request($args, $req_sum, \%ENV) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | ▶ | if (! $ref) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | $ref = $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | ▶ | $ref = eval { throw 'Trouble dispatching', {path => $ENV{'PATH_INFO'}, msg => $ref} } || $@ if !ref($ref) || !$ref->{'error'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
ref $ref and $ref->{"error"}
eval {
do {
throw('Trouble dispatching', {'path', $ENV{'PATH_INFO'}, 'msg', $ref})
}
} || $@
MC/DC0%0/2
ref $ref and $ref->{"error"}
ref $ref
$ref->{"error"}
MC/DC0%0/2
eval {
do {
throw('Trouble dispatching', {'path', $ENV{'PATH_INFO'}, 'msg', $ref})
}
} || $@
eval {
do {
throw('Trouble dispatching', {'path', $ENV{'PATH_INFO'}, 'msg', $ref})
}
}
$@
Truth table0%0/3
A and B
A= ref $refB= $ref->{"error"}
Truth table0%0/3
A || B
A= eval {
do {
throw('Trouble dispatching', {'path', $ENV{'PATH_INFO'}, 'msg', $ref})
}
}B= $@
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | ▶ | local @$ref{keys %$_} = values %$_ if $_ = $self->{'_warn_info'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | warn $ref; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | ▶ | if ($old_out) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | select $old_out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | ▶ | warn "--- INVALID STDOUT ---\n$$out_ref\n" if $$out_ref; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | ▶ | if (ref($ref) eq 'ARRAY' && @$ref == 3 && $ref->[0] =~ /^\d+$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
ref $ref eq "ARRAY" and @$ref == 3 and $ref->[0] =~ /^\d+$/
ref $ref eq "ARRAY" and @$ref == 3
MC/DC0%0/3
ref $ref eq "ARRAY" and @$ref == 3 and $ref->[0] =~ /^\d+$/
ref $ref eq "ARRAY"
@$ref == 3
$ref->[0] =~ /^\d+$/
Truth table0%0/4
A and B and C
A= ref $ref eq "ARRAY"B= @$ref == 3C= $ref->[0] =~ /^\d+$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | ▶ | return $ref if $self->{'is_psgi'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | require Net::Server::PSGI; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | $self->Net::Server::PSGI::print_psgi_headers($ref->[0], $ref->[1]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | $self->Net::Server::PSGI::print_psgi_body($ref->[2]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | ▶ | $self->{'extra_headers'} = delete $ref->{'_extra_headers'} if $ref->{'_extra_headers'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | ▶ | my $out = eval { $self->json->encode($ref) } || do { warn "Trouble encoding json: $@"; "{'error':'Trouble encoding json - check server logs for details'}" }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
eval {
do {
$self->json->encode($ref)
}
} || do {
warn "Trouble encoding json: $@";
q[{'error':'Trouble encoding json - check server logs for details'}]
}
MC/DC0%0/2
eval {
do {
$self->json->encode($ref)
}
} || do {
warn "Trouble encoding json: $@";
q[{'error':'Trouble encoding json - check server logs for details'}]
}
eval {
do {
$self->json->encode($ref)
}
}
do {
warn "Trouble encoding json: $@";
q[{'error':'Trouble encoding json - check server logs for details'}]
}
Truth table0%0/3
A || B
A= eval {
do {
$self->json->encode($ref)
}
}B= do {
warn "Trouble encoding json: $@";
q[{'error':'Trouble encoding json - check server logs for details'}]
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | return $self->send_response($out); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | ▶ | sub _do_request { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_do_request: not called CC=8 SCAR=42.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | my ($self, $args, $req_sum, $env) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | my ($method, $brand, $extra) = $self->_map_request($args, $env); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | my $ver = $self->verify_sig($args, $req_sum, $env, $method, $brand); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | $self->{'_warn_info'} = {caller => {who => $args->{'_w'}, source => $args->{'_c'}, method => $method, brand => $brand, ip => $env->{'REMOTE_ADDR'}}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | local $env->{'REMOTE_USER'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | my $disp = $self->dispatch_factory->({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | ▶ | %{ $extra || {} }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/5
$extra || {}
delete $args->{'_t'} || do {
my $k = $self->config('admin_cookie_key');
$k ? $self->parse_cookies->{$k} : ''
}
MC/DC0%0/1
$extra || {}
$extra
MC/DC0%0/2
delete $args->{'_t'} || do {
my $k = $self->config('admin_cookie_key');
$k ? $self->parse_cookies->{$k} : ''
}
delete $args->{'_t'}
do {
my $k = $self->config('admin_cookie_key');
$k ? $self->parse_cookies->{$k} : ''
}
Truth table0%0/2
A
A= $extra
Truth table0%0/3
A || B
A= delete $args->{'_t'}B= do {
my $k = $self->config('admin_cookie_key');
$k ? $self->parse_cookies->{$k} : ''
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | is_server => $self->server_name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | ($env->{'HTTP_X_FORWARDED_FOR'} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | ? (api_ip => $env->{'HTTP_X_FORWARDED_FOR'}, is_proxy => $env->{'REMOTE_ADDR'}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | : (api_ip => $env->{'REMOTE_ADDR'})), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | api_auth => $ver, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | api_brand => $brand, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | api_method => $method, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | remote_user => delete($args->{'_w'}), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | remote_ip => delete($args->{'_i'}), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | ▶ | token => delete($args->{'_t'}) || do { my $k = $self->config('admin_cookie_key'); $k ? $self->parse_cookies->{$k} : '' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | caller => delete($args->{'_c'}), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | dbh_cache => $self->_dbh_cache, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | transport => $self->{'transport'}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | ▶ | $disp->server_init($method, $args, $self) if $disp->can('server_init'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | local $0 = "$0 ".$self->server_name." $method - $env->{'REMOTE_ADDR'}"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | ▶ | return $disp->run_method($method, $args) if !$disp->can('server_post_request'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | my $ref; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | my $ok = eval { $ref = $disp->run_method($method, $args); 1 }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | my $err = $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | $disp->server_post_request($method, $args, $ok, $ref, $err); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | ▶ | return $ref if $ok; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | die $err; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | ▶ | sub _map_request { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_map_request: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | my ($self, $args, $env) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | my $no_brand = $self->_no_brand; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | my ($meth, $brand) = ((!$no_brand || $no_brand < 0) && $env->{'PATH_INFO'} =~ m|^/+(.+)/([^/]+)$|) ? ($1, $2) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | : ($env->{'PATH_INFO'} =~ m|^/+(.+)$|) ? ($1, $no_brand ? undef : throw "Failed to find brand with method", {uri => "/$1"}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | ▶ | : throw "Failed to find method in URI", {uri => $env->{'PATH_INFO'}}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition0%0/6
!$no_brand || $no_brand < 0 and $env->{"PATH_INFO"} =~ m[^/+(.+)/([^/]+)$]
not $no_brand or $no_brand < 0
MC/DC0%0/3
!$no_brand || $no_brand < 0 and $env->{"PATH_INFO"} =~ m[^/+(.+)/([^/]+)$]
not $no_brand
$no_brand < 0
$env->{"PATH_INFO"} =~ m[^/+(.+)/([^/]+)$]
Truth table0%0/5
not(A) or B and C
A= not $no_brandB= $no_brand < 0C= $env->{"PATH_INFO"} =~ m[^/+(.+)/([^/]+)$]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | delete @$args{qw(_p _b)}; # legacy brand and password passing | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | return ($meth, $brand); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | ▶ | sub _dbh_cache { {} } # intentionally not persistent | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_dbh_cache: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | ▶ | sub cgi_obj { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cgi_obj: not called CC=9 SCAR=45.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | my ($self, $r) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | ▶ | return $self->{'cgi_obj'} ||= do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->{"cgi_obj"} ||= do {
eval {
do {
CGI::initialize_globals()
}
} or warn "Failed to initialize globals: $@" if $INC{"CGI.pm"};
eval {
do {
$self->{"is_psgi"} ? require CGI::PSGI : require CGI
}
} or throw("Cannot load CGI library during a non-JSON request", {"msg", $@, "type", $ENV{"CONTENT_TYPE"}});
local $CGI::POST_MAX = $self->max_request_size;
my $q = $self->{"is_psgi"} ? "CGI::PSGI"->new($self->{"is_psgi"}) : "CGI"->new($r || $self->{"apache_req"} || ())
}
MC/DC0%0/2
$self->{"cgi_obj"} ||= do {
eval {
do {
CGI::initialize_globals()
}
} or warn "Failed to initialize globals: $@" if $INC{"CGI.pm"};
eval {
do {
$self->{"is_psgi"} ? require CGI::PSGI : require CGI
}
} or throw("Cannot load CGI library during a non-JSON request", {"msg", $@, "type", $ENV{"CONTENT_TYPE"}});
local $CGI::POST_MAX = $self->max_request_size;
my $q = $self->{"is_psgi"} ? "CGI::PSGI"->new($self->{"is_psgi"}) : "CGI"->new($r || $self->{"apache_req"} || ())
}
$self->{"cgi_obj"}
do {
eval {
do {
CGI::initialize_globals()
}
} or warn "Failed to initialize globals: $@" if $INC{"CGI.pm"};
eval {
do {
$self->{"is_psgi"} ? require CGI::PSGI : require CGI
}
} or throw("Cannot load CGI library during a non-JSON request", {"msg", $@, "type", $ENV{"CONTENT_TYPE"}});
local $CGI::POST_MAX = $self->max_request_size;
my $q = $self->{"is_psgi"} ? "CGI::PSGI"->new($self->{"is_psgi"}) : "CGI"->new($r || $self->{"apache_req"} || ())
}
Truth table0%0/3
A ||= B
A= $self->{"cgi_obj"}B= do {
eval {
do {
CGI::initialize_globals()
}
} or warn "Failed to initialize globals: $@" if $INC{"CGI.pm"};
eval {
do {
$self->{"is_psgi"} ? require CGI::PSGI : require CGI
}
} or throw("Cannot load CGI library during a non-JSON request", {"msg", $@, "type", $ENV{"CONTENT_TYPE"}});
local $CGI::POST_MAX = $self->max_request_size;
my $q = $self->{"is_psgi"} ? "CGI::PSGI"->new($self->{"is_psgi"}) : "CGI"->new($r || $self->{"apache_req"} || ())
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | ▶ | eval { CGI::initialize_globals() } or warn "Failed to initialize globals: $@" if $INC{'CGI.pm'}; # CGI.pm caches query parameters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/5
$INC{'CGI.pm'} && (eval {
do {
CGI::initialize_globals()
}
} || warn("Failed to initialize globals: $@"))
eval {
do {
CGI::initialize_globals()
}
} or warn "Failed to initialize globals: $@"
MC/DC0%0/2
$INC{'CGI.pm'} && (eval {
do {
CGI::initialize_globals()
}
} || warn("Failed to initialize globals: $@"))
$INC{'CGI.pm'}
eval {
do {
CGI::initialize_globals()
}
}
Truth table0%0/3
A && B
A= $INC{'CGI.pm'}B= eval {
do {
CGI::initialize_globals()
}
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | ▶ | eval { $self->{'is_psgi'} ? require CGI::PSGI : require CGI } || throw 'Cannot load CGI library during a non-JSON request', {msg => $@, type => $ENV{'CONTENT_TYPE'}}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | local $CGI::POST_MAX = $self->max_request_size; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | ▶ | my $q = $self->{'is_psgi'} ? CGI::PSGI->new($self->{'is_psgi'}) : CGI->new($r || $self->{'apache_req'} || ()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$r || $self->{'apache_req'} || ()
$r or $self->{"apache_req"}
MC/DC0%0/3
$r || $self->{'apache_req'} || ()
$r
$self->{"apache_req"}
()
Truth table0%0/4
A or B || C
A= $rB= $self->{"apache_req"}C= ()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | ▶ | sub parse_form { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_form: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | my ($self, $r) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | my $q = $self->cgi_obj($r); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 0 | ▶ | return {map {my @v = $q->param($_); $_ => (@v <= 1 ? $v[0] : \@v)} $q->param}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | ▶ | sub parse_cookies { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_cookies: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | my ($self, $r) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | ▶ | my $env = $self->{'is_psgi'} || \%ENV; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{'is_psgi'} || \%ENV
MC/DC0%0/1
$self->{'is_psgi'} || \%ENV
$self->{'is_psgi'}
Truth table0%0/2
A
A= $self->{'is_psgi'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | ▶ | return {} if !$env->{'HTTP_COOKIE'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | my $q = $self->cgi_obj($r); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | ▶ | return {map {my @v = $q->cookie($_); $_ => (@v <= 1 ? $v[0] : \@v)} $q->cookie}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | ▶ | sub content_type { shift->{'content_type'} ||= 'application/json' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
content_type: not called CC=2 SCAR=17.9
Pod
undocumented
Condition0%0/2
+(shift())->{"content_type"} ||= "application/json"
MC/DC0%0/1
+(shift())->{"content_type"} ||= "application/json"
+(shift())->{"content_type"}
Truth table0%0/2
A
A= +(shift())->{"content_type"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | ▶ | sub send_response { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
send_response: not called CC=13 SCAR=52.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | my ($self, $str) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | ▶ | $str =~ s/\s*$/\r\n/ if $self->content_type =~ m{^(?:text/|application/json$)}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | ▶ | my @extra = $self->{'extra_headers'} ? @{ $self->{'extra_headers'} } : (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | ▶ | if ($self->{'is_psgi'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | return [200, [(map {$_->[0], $_->[1]} @extra), 'Content-type' => $self->content_type, 'Content-length' => length($str)], [$str]]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | ▶ | } elsif (my $r = $self->{'apache_req'} || eval { $ENV{'MOD_PERL'} && Apache2::RequestUtil->request }) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
$self->{'apache_req'} || eval {
do {
$ENV{'MOD_PERL'} and 'Apache2::RequestUtil'->request
}
}
$ENV{'MOD_PERL'} && 'Apache2::RequestUtil'->request
MC/DC0%0/2
$self->{'apache_req'} || eval {
do {
$ENV{'MOD_PERL'} and 'Apache2::RequestUtil'->request
}
}
$self->{'apache_req'}
eval {
do {
$ENV{'MOD_PERL'} and 'Apache2::RequestUtil'->request
}
}
MC/DC0%0/2
$ENV{'MOD_PERL'} && 'Apache2::RequestUtil'->request
$ENV{'MOD_PERL'}
'Apache2::RequestUtil'->request
Truth table0%0/3
A || B
A= $self->{'apache_req'}B= eval {
do {
$ENV{'MOD_PERL'} and 'Apache2::RequestUtil'->request
}
}
Truth table0%0/3
A && B
A= $ENV{'MOD_PERL'}B= 'Apache2::RequestUtil'->request
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | $r->headers_out->set($_->[0] => $_->[1]) for @extra; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | $r->headers_out->set('Content-length', length($str)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | $r->content_type($self->content_type); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | $r->print($str); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | } elsif (my $c = $self->{'server'}->{'client'}) { # accelerate output header generation under Net::Server | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | my $ri = $self->{'request_info'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | my $out = "HTTP/1.0 200 OK\015\012"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | foreach my $row (@{ $self->http_base_headers }, @extra, ['Content-length', length($str)], ['Content-type', $self->content_type]) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | $out .= "$row->[0]: $row->[1]\015\012"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | push @{ $ri->{'response_headers'} }, $row; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | $ri->{'response_header_size'} += length $out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | $ri->{'http_version'} = '1.0'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | $ri->{'response_status'} = 200; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | $ri->{'headers_sent'} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | $ri->{'response_size'} = length $str; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | $c->print("$out\015\012$str"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | # Otherwise, this is a normal CGI process. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | # XXX - Do we need to also convert "Status" header for the special NPH format? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | ▶ | print "HTTP/1.0 200 OK\r\n" if ($ENV{SCRIPT_FILENAME} // "") =~ m{/nph-[^/]+($|\s)}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$ENV{"SCRIPT_FILENAME"} // ""
MC/DC0%0/1
$ENV{"SCRIPT_FILENAME"} // ""
$ENV{"SCRIPT_FILENAME"}
Truth table0%0/2
A
A= $ENV{"SCRIPT_FILENAME"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | for my $h (@extra) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | print "$h->[0]: $h->[1]\r\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | print "Content-Type: ".$self->content_type."\r\nContent-Length: ".length($str)."\r\nContent-Type: ".$self->content_type."\r\n\r\n",$str; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | ▶ | sub _no_brand { shift->config(no_brand => undef) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_no_brand: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | ▶ | sub verify_sig { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
verify_sig: not called CC=40 SCAR=74.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | my ($self, $args, $req_sum, $env, $meth, $brand) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | my ($ip, $sig, $script, $path_info, $qs, $auth) = @$env{qw(REMOTE_ADDR HTTP_X_RESPITE_AUTH SCRIPT_NAME PATH_INFO QUERY_STRING HTTP_AUTHORIZATION)}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | ▶ | my $uri = $script || throw "Missing script"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$script || throw('Missing script')
MC/DC0%0/2
$script || throw('Missing script')
$script
throw('Missing script')
Truth table0%0/3
A || B
A= $scriptB= throw('Missing script')
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | ▶ | $uri .= $path_info if $path_info; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | ▶ | $uri .= "?$qs" if $qs; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | my ($type, $user, $exception); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | ▶ | if ($auth) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | ▶ | throw "Cannot pass both Authorization and X-Respite-Auth", {authorization => $auth, x_respite_auth => $sig, uri => $uri, ip => $ip} if $sig; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | ▶ | if ($auth =~ s/^Basic \s+ (\S+)$/$1/x) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | $type = 'basic'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | require MIME::Base64; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | ($user, $sig) = split /:/, MIME::Base64::decode_base64($auth), 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | ▶ | $exception = Throw->new("Basic authentication not allowed", {user => $user}) if ! $self->allow_auth_basic($brand, $user); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | } elsif ($auth =~ s/^Digest \s+//x) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | $type = 'digest'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | $sig->{'method'} = $ENV{'REQUEST_METHOD'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | ▶ | $sig->{$1} = (defined($3) && length($3)) ? $3 : $2 while $auth =~ s/^ (\w+) = (?: "([^\"]+)" | ([^\s\",]+)) (?:\s*$|,\s*) //gxs; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
defined $3 and length $3
MC/DC0%0/2
defined $3 and length $3
defined $3
length $3
Truth table0%0/3
A and B
A= defined $3B= length $3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | $user = $sig->{'username'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | } elsif ($auth =~ s/^RespiteAuth \s+//x) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | $type = 'signed'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | $sig = $auth; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | $exception = Throw->new("Unknown auth type", {authorization => $auth, uri => $uri, ip => $ip, authtype => 'unknown'}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | my $allow_md5 = $self->allow_auth_md5_pass($brand); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | ▶ | $sig ||= $args->{'x_respite_auth'} if $allow_md5; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$sig ||= $args->{"x_respite_auth"}
MC/DC0%0/2
$sig ||= $args->{"x_respite_auth"}
$sig
$args->{"x_respite_auth"}
Truth table0%0/3
A ||= B
A= $sigB= $args->{"x_respite_auth"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | ▶ | $type = !$sig ? 'none' : ($sig !~ /^[a-f0-z]{32}$/) ? 'signed' : $allow_md5 ? 'md5_pass' : throw 'Auth type md5_pass not allowed'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | ▶ | my $pass = $self->get_api_pass($brand || '', $ip, $sig, $type, $user, $exception) || []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/4
$self->get_api_pass($brand || '', $ip, $sig, $type, $user, $exception) || []
$brand || ''
MC/DC0%0/1
$self->get_api_pass($brand || '', $ip, $sig, $type, $user, $exception) || []
$self->get_api_pass($brand || '', $ip, $sig, $type, $user, $exception)
MC/DC0%0/1
$brand || ''
$brand
Truth table0%0/2
A
A= $self->get_api_pass($brand || '', $ip, $sig, $type, $user, $exception)
Truth table0%0/2
A
A= $brand
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | ▶ | $pass = ref($pass) ? undef : [$pass] if ref($pass) ne 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | ▶ | return {authorization_not_required => 1, ip => $ip, brand => $brand, authtype => $type, exception => $exception} if $pass && !@$pass; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$pass and not @$pass
MC/DC0%0/2
$pass and not @$pass
$pass
not @$pass
Truth table0%0/3
A and not(B)
A= $passB= not @$pass
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | ▶ | die $exception if defined $exception; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | ▶ | throw "Missing client authorization", {server_name => $self->server_name, ip => $ip, brand => $brand, authtype => $type, uri => $uri} if !$sig && $type && $type ne 'none'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
not $sig and $type and $type ne "none"
not $sig and $type
MC/DC0%0/3
not $sig and $type and $type ne "none"
not $sig
$type
$type ne "none"
Truth table0%0/4
not(A) and B and C
A= not $sigB= $typeC= $type ne "none"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | ▶ | if ($pass) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | for my $i (0 .. $#$pass) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | next if ($type eq 'basic') ? $pass->[$i] ne $sig | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | : ($type eq 'md5_pass') ? md5_hex($pass->[$i]) ne $sig | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 0 | ▶ | : ($type eq 'signed') ? do { my ($_sum, $time) = split /:/, $sig, 2; md5_hex("$pass->[$i]:$time:$uri:$req_sum") ne $_sum } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 0 | ▶ | : ($type eq 'digest') ? (eval { $self->verify_digest($sig||={}, $pass->[$i], $uri, $req_sum, $meth, $brand, $ip) } ? 0 : do { $sig->{'verify'} = $@; 1 }) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
Condition0%0/2
$sig ||= {}
MC/DC0%0/1
$sig ||= {}
$sig
Truth table0%0/2
A
A= $sig
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | : 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 0 | ▶ | return {authtype => $type, ip => $ip, brand => $brand, meth => $meth, i => $i, ($self->{'verify_sig_return_pass'} ? (pass => $pass->[$i]) : ()), ($type eq 'digest'?(digest=>$sig):())}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | ▶ | throw "Invalid client authorization", {($type eq 'digest'?(digest=>$sig):()), server_name => $self->server_name, ip => $ip, brand => $brand, authtype => $type, uri => $uri}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | my %cidr; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | ▶ | sub get_api_pass { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_api_pass: not called CC=25 SCAR=64.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | my ($self, $brand, $ip, $sig, $type, $user, $except) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | my $ref = $self->config(pass => undef); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 0 | ▶ | return $ref if ! ref($ref) || ref($ref) eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not ref $ref or ref $ref eq "ARRAY"
MC/DC0%0/2
not ref $ref or ref $ref eq "ARRAY"
not ref $ref
ref $ref eq "ARRAY"
Truth table0%0/3
not(A) or B
A= not ref $refB= ref $ref eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | ▶ | if (exists $ref->{$ip}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | ▶ | return $ref->{$ip} if ref($ref->{$ip}) ne 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | ▶ | return $ref->{$ip}->{$brand} if exists $ref->{$ip}->{$brand}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 0 | ▶ | return $ref->{$ip}->{'~default~'} if exists $ref->{$ip}->{'~default~'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | ▶ | return $ref->{$ip}->{'-default'} if exists $ref->{$ip}->{'-default'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | } elsif (exists $ref->{$brand}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 0 | ▶ | return $ref->{$brand} if ref($ref->{$brand}) ne 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 0 | ▶ | return $ref->{$brand}->{$ip} if exists $ref->{$brand}->{$ip}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | ▶ | return $ref->{$brand}->{'~default~'} if exists $ref->{$brand}->{'~default~'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | ▶ | return $ref->{$brand}->{'-default'} if exists $ref->{$brand}->{'-default'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | ▶ | } elsif (my $c = $ref->{'~cidr~'} || $ref->{'-cidr'}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$ref->{'~cidr~'} || $ref->{'-cidr'}
MC/DC0%0/2
$ref->{'~cidr~'} || $ref->{'-cidr'}
$ref->{'~cidr~'}
$ref->{'-cidr'}
Truth table0%0/3
A || B
A= $ref->{'~cidr~'}B= $ref->{'-cidr'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | my $n = _aton($ip); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | foreach my $cidr (keys %$c) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | ▶ | my $range = $cidr{$cidr} ||= _cidr($cidr); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$cidr{$cidr} ||= _cidr($cidr)
MC/DC0%0/2
$cidr{$cidr} ||= _cidr($cidr)
$cidr{$cidr}
_cidr($cidr)
Truth table0%0/3
A ||= B
A= $cidr{$cidr}B= _cidr($cidr)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | ▶ | next if $n < $range->[0] || $n > $range->[1]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$n < $range->[0] or $n > $range->[1]
MC/DC0%0/2
$n < $range->[0] or $n > $range->[1]
$n < $range->[0]
$n > $range->[1]
Truth table0%0/3
A or B
A= $n < $range->[0]B= $n > $range->[1]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 0 | my $ref = $c->{$cidr}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 0 | ▶ | if (ref($ref) eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 0 | ▶ | return $ref->{$brand} if exists $ref->{$brand}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | ▶ | return $ref->{'~default~'} if exists $ref->{'~default~'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 0 | ▶ | return $ref->{'-default'} if exists $ref->{'-default'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | return $ref; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | ▶ | return $ref->{'~default~'} if exists $ref->{'~default~'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 0 | ▶ | return $ref->{'-default'} if exists $ref->{'-default'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | throw "Not authorized - Could not find brand/ip match in pass configuration", {brand => $brand, ip => $ip, service => $self->server_name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | ▶ | sub _aton { my $ip = shift; return unpack "N", pack "C4", split /\./, $ip } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_aton: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | ▶ | sub _cidr { (my $c = shift) =~ s/\s+//; my ($ip, $base) = split /\//, $c; my $i = _aton($ip); $i &= 2**32 - 2**(32-$base) if !$_[0]; return [$i, $i+2**(32-$base)-1] } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_cidr: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 0 | ▶ | sub allow_auth_md5_pass { shift->config(allow_auth_md5_pass => undef) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
allow_auth_md5_pass: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 0 | ▶ | sub allow_auth_basic { shift->config(allow_auth_basic => undef) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
allow_auth_basic: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 0 | ▶ | sub allow_auth_qop_auth { shift->config(allow_auth_qop_auth => undef) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
allow_auth_qop_auth: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | ▶ | sub digest_realm { shift->config(realm => sub { my $name = shift->server_name; return $name =~ /^(\w+)_server/ ? $1 : $name }) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Subroutine
digest_realm: not called CC=1 SCAR=6.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 0 | ▶ | sub verify_digest { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
verify_digest: not called CC=10 SCAR=47.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 0 | my ($self, $digest, $pass, $uri, $req_sum, $meth, $brand, $ip) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 0 | ▶ | my $d = sub { my ($key, $opt) = @_; my $val = $digest->{$key}; $opt ? ($val='') : throw "Digest directive $key was missing" if !defined($val) || !length($val); $val }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
Branch: 2 branches
Condition0%0/3
defined $val and length $val
MC/DC0%0/2
defined $val and length $val
defined $val
length $val
Truth table0%0/3
A and B
A= defined $valB= length $val
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 0 | ▶ | throw "Missing or invalid digest username" if $brand && $d->('username') ne $brand; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$brand and &$d("username") ne $brand
MC/DC0%0/2
$brand and &$d("username") ne $brand
$brand
&$d("username") ne $brand
Truth table0%0/3
A and B
A= $brandB= &$d("username") ne $brand
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 0 | ▶ | throw "Missing or invalid digest realm", {realm => $self->digest_realm} if $d->('realm') ne $self->digest_realm; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 0 | ▶ | throw "Digest URI did not match", {digest => $d->('uri'), actual => $uri} if $uri ne $d->('uri'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 0 | my $ha1 = md5_hex($d->('username') .':'. $d->('realm').":$pass"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 0 | ▶ | $ha1 = md5_hex("$ha1:".$d->('nonce').':'.$d->('cnonce')) if lc($d->('algorithm',1)) eq 'md5-sess'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 0 | ▶ | my $ha2 = md5_hex($d->('method').":$uri".(($d->('qop',1) eq 'auth-int') ? ":$req_sum" : $self->allow_auth_qop_auth($brand) ? '' : throw 'Digest qop auth not allowed')); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 0 | ▶ | my $sum = md5_hex("$ha1:".$d->('nonce').($d->('qop',1) ? ':'.$d->('nc').':'.$d->('cnonce').':'.$d->('qop') : '').":$ha2"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 0 | ▶ | throw 'Digest did not validate' if $sum ne $d->('response'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | ###----------------------------------------------------------------### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | # Net::Server::HTTP bits | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 5 | ▶ | sub server_args { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
server_args: called CC=21 SCAR=41.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 5 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 5 | my $name = $self->server_name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 5 | ▶ | my $val = sub { my ($key, $def) = @_; $self->config($key, $def, $name) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 5 | ▶ | my $path = $val->(path => ($name =~ /^(\w+)_server/ ? $1 : $name)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 5 | my $host = $val->(host => '*'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 5 | my $port = $val->(port => 443); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 5 | my $ssl = !$val->(no_ssl => undef); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 5 | ▶ | my $ad = $val->(auto_doc => ''); $ad = ($name =~ /^(\w+)_server/ ? $1 : $name).'_doc' if $ad && $ad eq '1'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
$ad and $ad eq 1
MC/DC0%0/2
$ad and $ad eq 1
$ad
$ad eq 1
Truth table33%1/3
A and B
A= $adB= $ad eq 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 5 | ▶ | my $is_dev = eval { defined(&config::is_dev) && config::is_dev() }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
defined &config::is_dev && config::is_dev()
MC/DC0%0/2
defined &config::is_dev && config::is_dev()
defined &config::is_dev
config::is_dev()
Truth table33%1/3
A && B
A= defined &config::is_devB= config::is_dev()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 5 | ▶ | my $use_dev_port = $is_dev && $ssl && !$val->(no_dev_port => ''); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%2/6
$is_dev && $ssl && !&$val('no_dev_port', '')
$is_dev and $ssl
MC/DC0%0/3
$is_dev && $ssl && !&$val('no_dev_port', '')
$is_dev
$ssl
!&$val('no_dev_port', '')
Truth table25%1/4
A and B && not(C)
A= $is_devB= $sslC= !&$val('no_dev_port', '')
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 5 | my $res = $val->(cgi_bin => undef); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 5 | ▶ | my $app = !$res ? \&cgihandler : ($res ne 1) ? $res : 'cgi-bin/'.($name =~ /^(\w+)_server/ ? $1 : $name); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 5 | ▶ | $app = $self->rootdir_server ."/$app" if !ref($app) && $app !~ /^\//; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $app or $app =~ m[^/]
MC/DC0%0/2
ref $app or $app =~ m[^/]
ref $app
$app =~ m[^/]
Truth table33%1/3
A or B
A= ref $appB= $app =~ m[^/]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 5 | my $st = $val->(server_type => 'PreFork'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | server_type => ref($st) ? $st : [$st], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | enable_dispatch => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | ipv => 4, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 5 | ▶ | app => [[(map{$_ => $app} ref($path) ? @$path : $path), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 7 branches
Condition33%1/3
$is_dev and $ssl
MC/DC0%0/2
$is_dev and $ssl
$is_dev
$ssl
Truth table33%1/3
A and B
A= $is_devB= $ssl
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | ($ad ? ($ad => \&cgidoc) : ()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | '' => \&http_not_found]], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | port => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | {port => $port, host => $host, ($ssl ? (proto => 'SSL') : ())}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | ($use_dev_port ? {port => ($port == 443 ? 80 : $port-1), host => $host} : ()), # allow for dev to telnet to a non-ssl | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | serialize => ($is_dev && $ssl) ? 'flock' : 'none', # can only do if hard coded to ipv4 and host resolves to one ip | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | access_log_file => $val->(access_log_file => "/var/log/${name}/${name}.access_log"), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | log_file => $val->(log_file => "/var/log/${name}/${name}.error_log"), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | pid_file => $val->(pid_file => "/var/run/${name}.pid"), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | user => $val->(user => 'readonly'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | group => $val->(group => 'cvs'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 0 | ▶ | sub rootdir_server { shift->config(rootdir_server => $config::config{'rootdir_server'} || sub { require FindBin; $FindBin::RealBin }) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Subroutine
rootdir_server: not called CC=2 SCAR=17.9
Pod
documented
Condition0%0/3
$config::config{'rootdir_server'} || sub {
require FindBin;
$FindBin::RealBin;
}
MC/DC0%0/2
$config::config{'rootdir_server'} || sub {
require FindBin;
$FindBin::RealBin;
}
$config::config{'rootdir_server'}
sub {
require FindBin;
$FindBin::RealBin;
}
Truth table0%0/3
A || B
A= $config::config{'rootdir_server'}B= sub {
require FindBin;
$FindBin::RealBin;
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 0 | ▶ | sub SSL_base_domain { 'example.com' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
SSL_base_domain: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 0 | ▶ | sub SSL_cert_file { shift->config(ssl_cert => sub { shift->rootdir_server .shift->SSL_base_domain().'.crt' }) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
SSL_cert_file: not called CC=1 SCAR=6.9
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 0 | ▶ | sub SSL_key_file { shift->config(ssl_key => sub { shift->rootdir_server .shift->SSL_base_domain().'.key' }) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
SSL_key_file: not called CC=1 SCAR=6.9
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 2 | ▶ | sub post_bind { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
post_bind: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 2 | $0 = $self->server_name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 2 | $self->SUPER::post_bind(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 0 | ▶ | sub child_init_hook { $0 = shift->server_name ." - waiting" } # prefork server | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
child_init_hook: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 0 | ▶ | sub run_client_connection { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run_client_connection: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 0 | $0 = $self->server_name . " - connected"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 0 | $self->SUPER::run_client_connection(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 0 | ▶ | $_->($self) for @{ $self->{'post_client_callbacks'} || [] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{'post_client_callbacks'} || []
MC/DC0%0/1
$self->{'post_client_callbacks'} || []
$self->{'post_client_callbacks'}
Truth table0%0/2
A
A= $self->{'post_client_callbacks'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 0 | ▶ | sub server_revision { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
server_revision: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 0 | ▶ | return $self->{'server_revision'} ||= $self->server_name.'/'.$self->revision.($self->{'nshv'} ? ' '.$self->SUPER::server_revision : ''); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$self->{"server_revision"} ||= $self->server_name . '/' . $self->revision . ($self->{"nshv"} ? ' ' . $self->SUPER::server_revision : "")
MC/DC0%0/1
$self->{"server_revision"} ||= $self->server_name . '/' . $self->revision . ($self->{"nshv"} ? ' ' . $self->SUPER::server_revision : "")
$self->{"server_revision"}
Truth table0%0/2
A
A= $self->{"server_revision"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 0 | ▶ | sub http_not_found { shift->send_status(404, "Not found", "<h1>Not Found</h1>") } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
http_not_found: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 0 | ▶ | sub post_process_request_hook { $0 = shift->server_name ." - post_request" } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
post_process_request_hook: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 8 | ▶ | sub default_values { {background => 1, setsid => 1} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
default_values: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | ###----------------------------------------------------------------### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | # Net::Server::HTTP daemonization bits | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 2 | ▶ | sub run_server { shift->SUPER::run(@_) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run_server: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 0 | ▶ | sub run { throw "Use either run_server or run_commandline for clarity" } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 0 | ▶ | sub run_commandline { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run_commandline: not called CC=13 SCAR=52.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 0 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 0 | ▶ | my $sub = $ARGV[0] && $class->can("__$ARGV[0]") ? "__$ARGV[0]" : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$ARGV[0] and $class->can("__$ARGV[0]")
MC/DC0%0/2
$ARGV[0] and $class->can("__$ARGV[0]")
$ARGV[0]
$class->can("__$ARGV[0]")
Truth table0%0/3
A and B
A= $ARGV[0]B= $class->can("__$ARGV[0]")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 0 | ▶ | shift(@ARGV) if $sub; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 0 | ▶ | if ($ENV{'BOUND_SOCKETS'}) { # HUP | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | 0 | ▶ | my $self = ref($class) ? $class : $class->new(@_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 0 | $self->run_server; # will exit | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 0 | warn "Failed to re-initialize server during HUP\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 0 | exit 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | } elsif ($sub) { # commandline server service | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 0 | ▶ | local $ENV{'NO_PRELOAD'} = 1 if $sub !~ /^__(?:start|restart|reload)$/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 0 | ▶ | my $self = ref($class) ? $class : $class->new(@_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 0 | $self->$sub(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | } elsif ($ENV{'PLACK_ENV'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 0 | return $class->psgi_app(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | } elsif (!@ARGV) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 0 | throw "$0 help|start|restart|reload|stop|status|tail_error|tail_access|ps|(or any Respite commands)"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 0 | ▶ | my $args = ref($_[0]) ? shift : {@_}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 0 | ▶ | my $self = ref($class) ? $class : $class->new({%$args, non_daemon => 1}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 0 | require Net::Respite::CommandLine; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 0 | Net::Respite::CommandLine->run({dispatch_factory => $self->dispatch_factory}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 0 | exit 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | 0 | ▶ | sub psgi_app { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
psgi_app: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 0 | my ($class, $args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 0 | require IO::Socket; require Net::Server; require Net::Server::PreFork; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 0 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 0 | local *ENV = my $env = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 0 | ▶ | return $class->cgihandler({%{$args||{}}, non_daemon => 1, is_psgi => $env}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$args || {}
MC/DC0%0/1
$args || {}
$args
Truth table0%0/2
A
A= $args
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 3 | ▶ | sub _get_pid { # taken from Net::Server::Daemonize::check_pid_file - but modified | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_pid: called CC=5 SCAR=16.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 3 | my $pid_file = $self->{'server'}->{'pid_file'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | 3 | ▶ | return if ! -e $pid_file; # no pid_file = return success | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 3 | ▶ | return if -z $pid_file; # empty pid_file = return success | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 3 | ▶ | open my $fh, '<', $pid_file or throw "Could not open existing pid_file", {file => $pid_file, msg => $!}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 3 | my $line = <$fh>; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 3 | close $fh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 3 | ▶ | return ($line =~ /^(\d{1,10})$/) ? $1 : throw "Could not find pid in existing pid_file", {line => $line}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | 3 | ▶ | sub _ok { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ok: called CC=2 SCAR=7.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | 3 | my ($ok, $msg) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | 3 | ▶ | warn "$msg\e[60G[". ($ok ? "\e[1;32m OK " : "\e[1;31mFAILED") ."\e[0;39m]\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 0 | ▶ | sub __status { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__status: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 0 | my $pid = $self->_get_pid; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 0 | ▶ | return _ok(0, "Process is not running - no pid") if ! $pid; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | 0 | ▶ | return _ok(1, "Process appears to be running under pid $pid") if kill 0, $pid; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 0 | return _ok(0, "Process does not appear to be running - last pid: $pid"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | 0 | ▶ | sub __start { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__start: not called CC=8 SCAR=42.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 0 | my $pid = $self->_get_pid; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 0 | ▶ | if ($pid && kill(0, $pid)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$pid and kill 0, $pid
MC/DC0%0/2
$pid and kill 0, $pid
$pid
kill 0, $pid
Truth table0%0/3
A and B
A= $pidB= kill 0, $pid
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | 0 | _ok(0, "Starting - pid already exists"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | 0 | throw "Process appears to already be running under pid $pid ... aborting"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | 0 | my $pid_file = $self->{'server'}->{'pid_file'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 0 | ▶ | if (-e $pid_file) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 0 | ▶ | unlink $pid_file or throw "Failed to unlink pid file", {file => $pid_file, msg => $!}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 0 | require Net::Server::Daemonize; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | 0 | ▶ | if (! Net::Server::Daemonize::safe_fork()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | # child | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | 0 | $self->run_server(); # will exit | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | 0 | _ok(0, "Server run failed - check log"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 0 | exit 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | 0 | sleep 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | 0 | $pid = $self->_get_pid; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 0 | ▶ | if (!$pid || ! kill 0, $pid) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$pid and kill 0, $pid
MC/DC0%0/2
$pid and kill 0, $pid
$pid
kill 0, $pid
Truth table0%0/3
A and B
A= $pidB= kill 0, $pid
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 0 | _ok(0, "Starting - new pid not started - check log for details"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | 0 | warn "Log file: $self->{'server'}->{'log_file'}\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 0 | exit 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | # could attempt connection to test for open success | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | 0 | _ok(1, "Started server"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | 3 | ▶ | sub __stop { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__stop: called CC=8 SCAR=24.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 3 | my $pid = $self->_get_pid; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 3 | my $name = $self->server_name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 3 | ▶ | if (!$pid) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 0 | return _ok(1, "Already Stopped $name"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | } elsif (! kill 0, $pid) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 0 | warn "Cannot kill 0 $pid while stopping: $!\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 0 | return _ok(0, "Failed to stop $name"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | 3 | ▶ | if (! (kill(15, $pid) || kill(9, $pid))) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
kill 15, $pid or kill 9, $pid
MC/DC0%0/2
kill 15, $pid or kill 9, $pid
kill 15, $pid
kill 9, $pid
Truth table33%1/3
A or B
A= kill 15, $pidB= kill 9, $pid
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | 0 | warn "Failed to kill TERM or KILL pid $pid while stopping\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 0 | return _ok(0, "Failed to stop $name"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | 3 | for (1 .. 25) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | 22 | ▶ | return _ok(1, "Stopped $name") if !kill 0, $pid; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 19 | sleep 0.2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | 19 | require POSIX; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 19 | ▶ | 1 while waitpid(-1, POSIX::WNOHANG()) > 0; # handle rare non-setsid uses of run and _stop | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | 0 | _ok(0, "Stopping - pid still running"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | 0 | exit 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | 0 | ▶ | sub __restart { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__restart: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | 0 | $self->__stop; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | 0 | $self->__start; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | 0 | ▶ | sub __reload { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__reload: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | 0 | my $pid = $self->_get_pid; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | 0 | ▶ | if (!$pid) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | 0 | _ok(1, "Process appears to be stopped already - attempting start"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | 0 | return $self->__start; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | } elsif (! kill 0, $pid) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 0 | _ok(1, "Process appears to be stopped (kill 0) - attempting start"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | 0 | return $self->__start; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | 0 | ▶ | if (! kill 1, $pid) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | 0 | _ok(0, "Reload failed: $!"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | 0 | exit 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | 0 | sleep 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | 0 | ▶ | if (kill 0, $pid) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | 0 | _ok(1, "Reloaded server"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | 0 | _ok(0, "Sent HUP - but server is gone away - attempting start"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | 0 | $self->__start; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | 0 | ▶ | sub __size_access { shift->__size_error('access_log_file') } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__size_access: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | 0 | ▶ | sub __size_error { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__size_error: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | 0 | my ($self, $file) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | 0 | ▶ | $file = $self->{'server'}->{$file || 'log_file'} || throw "No log_file to size"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/5
$self->{'server'}{$file or 'log_file'} || throw('No log_file to size')
$file || 'log_file'
MC/DC0%0/2
$self->{'server'}{$file or 'log_file'} || throw('No log_file to size')
$self->{'server'}{$file or 'log_file'}
throw('No log_file to size')
MC/DC0%0/1
$file || 'log_file'
$file
Truth table0%0/3
A || B
A= $self->{'server'}{$file or 'log_file'}B= throw('No log_file to size')
Truth table0%0/2
A
A= $file
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | 0 | return -s $file; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | 3 | ▶ | sub __tail_access { shift->__tail_error(shift(), 'access_log_file') } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__tail_access: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | 6 | ▶ | sub __tail_error { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__tail_error: called CC=7 SCAR=21.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | 6 | my ($self, $how, $file) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | 6 | ▶ | $how = quotemeta($how || shift(@ARGV) || 'f'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition40%2/5
$how || shift @ARGV || 'f'
$how or shift @ARGV
MC/DC0%0/2
$how || shift @ARGV || 'f'
$how
shift @ARGV
Truth table33%1/3
A or B
A= $howB= shift @ARGV
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | 6 | ▶ | $file = quotemeta($self->{'server'}->{$file || 'log_file'} || throw "No log_file to tail"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition60%3/5
$self->{'server'}{$file or 'log_file'} || throw('No log_file to tail')
$file || 'log_file'
MC/DC0%0/2
$self->{'server'}{$file or 'log_file'} || throw('No log_file to tail')
$self->{'server'}{$file or 'log_file'}
throw('No log_file to tail')
MC/DC100%1/1
$file || 'log_file'
$file
Truth table33%1/3
A || B
A= $self->{'server'}{$file or 'log_file'}B= throw('No log_file to tail')
Truth table100%2/2
A
A= $file
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | 6 | my $cmd = "tail -$how $file"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | 6 | warn "$cmd\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | 6 | ▶ | exec $cmd if $how eq 'f'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | 6 | ▶ | warn `$cmd` || "No error log\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
`$cmd` || "No error log\n"
MC/DC0%0/1
`$cmd` || "No error log\n"
`$cmd`
Truth table50%1/2
A
A= `$cmd`
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | 3 | ▶ | sub __ps { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ps: called CC=3 SCAR=11.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | 3 | my $name = shift->server_name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | 3 | ▶ | my $out = join '', grep {$_ =~ $name && $_ !~ /\b(?:watch|ps)\b/} `ps auwx`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$_ =~ /$name/ && !($_ =~ /\b(?:watch|ps)\b/)
MC/DC50%1/2
$_ =~ /$name/ && !($_ =~ /\b(?:watch|ps)\b/)
$_ =~ /$name/
!($_ =~ /\b(?:watch|ps)\b/)
Truth table66%2/3
A && not(B)
A= $_ =~ /$name/B= !($_ =~ /\b(?:watch|ps)\b/)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | 3 | ▶ | warn $out || "No processes found\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$out || "No processes found\n"
MC/DC0%0/1
$out || "No processes found\n"
$out
Truth table50%1/2
A
A= $out
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | ###----------------------------------------------------------------### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | 0 | ▶ | sub cgidoc_brand { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cgidoc_brand: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | 0 | ▶ | return $self->config(no_brand => 0) ? undef : $self->config(brand => sub { eval { config::provider() } || $self->_configs->{'provider'} || do { warn "Missing brand"; '-' } }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
Branch: 2 branches
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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | 0 | ▶ | sub cgidoc { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cgidoc: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | 0 | ▶ | eval { CGI::initialize_globals() } or warn "Failed to initialize globals: $@" if $INC{'CGI.pm'}; # CGI.pm caches query parameters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/5
$INC{'CGI.pm'} && (eval {
do {
CGI::initialize_globals()
}
} || warn("Failed to initialize globals: $@"))
eval {
do {
CGI::initialize_globals()
}
} or warn "Failed to initialize globals: $@"
MC/DC0%0/2
$INC{'CGI.pm'} && (eval {
do {
CGI::initialize_globals()
}
} || warn("Failed to initialize globals: $@"))
$INC{'CGI.pm'}
eval {
do {
CGI::initialize_globals()
}
}
Truth table0%0/3
A && B
A= $INC{'CGI.pm'}B= eval {
do {
CGI::initialize_globals()
}
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | 0 | my $name = $self->server_name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | my $disp = $self->dispatch_factory->({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | is_server => "$name/doc", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | api_ip => $ENV{'REMOTE_ADDR'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | api_brand => $self->cgidoc_brand, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | 0 | remote_ip => $ENV{'REMOTE_ADDR'}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | remote_user => '-auto-doc-', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | # token and remote_user will be updated by auto_doc_class if it is based on App::_Admin | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | dbh_cache => {}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | transport => 'form-doc', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | 0 | my $class = $self->config(auto_doc_class => 'Net::Respite::AutoDoc'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | 0 | (my $file = "$class.pm") =~ s|::|/|g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | 0 | require $file; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | 0 | ▶ | $class->new({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | service => (($name =~ /^(\w+)_server/) ? $1 : $name), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | server => $self, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | api_obj => $disp, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | })->navigate; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | ###----------------------------------------------------------------### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | 4 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||