Lemonldap/NG/Handler/ApacheMP2/Request.pm

filter: Statementstmt 71.7% 28 / 39 Branchbran 25.0% 2 / 8 Conditioncond 20.0% 2 / 10 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 60.0% 6 / 10 Podpod 50.0% 2 / 4 totaltotal 51.9% 40 / 77 CC 9 SCAR 17.6
CC
9
Cov
56%
wantJSON
12.0
new
7.5
__ANON__
6.0
CRAP 5.8
« Lemonldap/NG/Handler/Lib/ZimbraPreAuth.pm ↑ Summary Plack/Middleware/Auth/LemonldapNG.pm »
1 package Lemonldap::NG::Handler::ApacheMP2::Request;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use base 'Lemonldap::NG::Common::PSGI::Request';
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Plack::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use URI;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use URI::Escape;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 1 our $VERSION = '2.23.0';
10  
11 # Build Plack::Request (inspired from Plack::Handler::Apache2)
12 1 ▶sub new {
Subroutine new: called CC=5 SCAR=20.2
Pod documented
13 1 my ( $class, $r ) = @_;
14  
15 # $r->subprocess_env breaks header modification. That's why it is not used
16 # here
17 1 my ( $uri, $args ) = ( $r->uri, $r->args );
18 1 ▶ my $uri_full = $uri . ( $args ? "?$args" : '' );
Branch: 1 branch
BranchTrueFalseTotal
$args ? : 0 1 1
19 my $env = {
20  
21 #%ENV,
22 HTTP_HOST => $r->hostname,
23 REMOTE_ADDR => $r->useragent_ip,
24 QUERY_STRING => $args,
25 REQUEST_URI => $uri_full,
26 PATH_INFO => '',
27 SERVER_PORT => $ENV{SERVER_PORT} || $r->get_server_port,
28 REQUEST_METHOD => $r->method,
29 UNIQUE_ID => $r->subprocess_env('UNIQUE_ID'),
30 'psgi.version' => [ 1, 1 ],
31 1 ▶ 'psgi.url_scheme' => ( $ENV{HTTPS} || 'off' ) =~ /^(?:on|1)$/i
Branch: 1 branch
BranchTrueFalseTotal
($ENV{'HTTPS'} || 'off') =~ /^(?:on|1)$/i ? : 0 1 1
Condition40%2/5
$ENV{'SERVER_PORT'} || $r->get_server_port
l!l&&r!l&&!r
010
$ENV{'HTTPS'} || 'off'
l!l
01
MC/DC0%0/2
$ENV{'SERVER_PORT'} || $r->get_server_port
$ENV{'SERVER_PORT'} $r->get_server_port
MC/DC0%0/1
$ENV{'HTTPS'} || 'off'
$ENV{'HTTPS'}
Truth table33%1/3
A || B
A= $ENV{'SERVER_PORT'}B= $r->get_server_port
ABresult
1X1
011
000
Truth table50%1/2
A
A= $ENV{'HTTPS'}
Aresult
11
00
32 ? 'https'
33 : 'http',
34 'psgi.input' => $r,
35 'psgi.errors' => *STDERR,
36 'psgi.multithread' => Plack::Util::FALSE,
37 'psgi.multiprocess' => Plack::Util::TRUE,
38 'psgi.run_once' => Plack::Util::FALSE,
39 'psgi.streaming' => Plack::Util::TRUE,
40 'psgi.nonblocking' => Plack::Util::FALSE,
41 'psgix.harakiri' => Plack::Util::TRUE,
42 'psgix.cleanup' => Plack::Util::TRUE,
43 'psgix.cleanup.handlers' => [],
44 'psgi.r' => $r,
45 };
46 $r->headers_in->do(
47 0 ▶ sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
48 0 my $h = shift;
49 0 my $k = uc($h);
50 0 ▶ if ( $k ne 'HOST' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($k ne "HOST") 0 0 0
51 0 $k =~ s/-/_/g;
52 0 $env->{"HTTP_$k"} = $r->headers_in->{$h};
53 }
54 0 return 1;
55 }
56 1 );
57 1 my $uri = URI->new( "http://" . $r->hostname . $r->unparsed_uri );
58 1 $env->{PATH_INFO} = uri_unescape( $uri->path );
59  
60 # Access control is decided on the URI httpd routed on ($r->uri, decoded
61 # and normalized), not on PATH_INFO, which is rebuilt here from the raw
62 # unparsed URI and where dot segments survive
63 1 $env->{ACCESS_CONTROL_URI} = $uri_full;
64  
65 1 my $self = Lemonldap::NG::Common::PSGI::Request->new($env);
66 1 bless $self, $class;
67 1 return $self;
68 }
69  
70 0 ▶sub data {
Subroutine data: not called CC=2 SCAR=17.9
Pod undocumented
71 0 my ($self) = @_;
72 0 ▶ return $self->{data} ||= {};
Condition0%0/2
$self->{"data"} ||= {}
l!l
00
MC/DC0%0/1
$self->{"data"} ||= {}
$self->{"data"}
Truth table0%0/2
A
A= $self->{"data"}
Aresult
11
00
73 }
74  
75 0 ▶sub wantJSON {
Subroutine wantJSON: not called CC=3 SCAR=24.8
Pod documented
76 return 1
77 if ( defined $_[0]->env->{HTTP_ACCEPT}
78 0 ▶ and $_[0]->env->{HTTP_ACCEPT} =~ m#(?:application|text)/json#i );
Branch: 1 branch
BranchTrueFalseTotal
if defined $_[0]->env->{"HTTP_ACCEPT"} and $_[0]->env->{"HTTP_ACCEPT"} =~ m[(?:application|text)/json]i 0 0 0
Condition0%0/3
defined $_[0]->env->{"HTTP_ACCEPT"} and $_[0]->env->{"HTTP_ACCEPT"} =~ m[(?:application|text)/json]i
!ll&&!rl&&r
000
MC/DC0%0/2
defined $_[0]->env->{"HTTP_ACCEPT"} and $_[0]->env->{"HTTP_ACCEPT"} =~ m[(?:application|text)/json]i
defined $_[0]->env->{"HTTP_ACCEPT"} $_[0]->env->{"HTTP_ACCEPT"} =~ m[(?:application|text)/json]i
Truth table0%0/3
A and B
A= defined $_[0]->env->{"HTTP_ACCEPT"}B= $_[0]->env->{"HTTP_ACCEPT"} =~ m[(?:application|text)/json]i
ABresult
0X0
100
111
79 0 return 0;
80 }
81  
82 0 ▶sub request_id { return $_[0]->env->{UNIQUE_ID} }
Subroutine request_id: not called CC=1 SCAR=6.9
Pod undocumented
83  
84 1 1;
« Lemonldap/NG/Handler/Lib/ZimbraPreAuth.pm ↑ Summary Plack/Middleware/Auth/LemonldapNG.pm »