blib/lib/Langertha/Knarr/PSGI/FakeReq.pm

filter: Statementstmt 36.3% 8 / 22 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 33.3% 2 / 6 Podpod 100% 4 / 4 totaltotal 35.9% 14 / 39 CC 5 SCAR 22.8
CC
5
Cov
29%
headers
20.0
path
6.0
new
2.0
CRAP 9.8
« blib/lib/Langertha/Knarr/Image.pm ↑ Summary blib/lib/Langertha/Knarr/Protocol.pm »
1 package Langertha::Knarr::PSGI::FakeReq;
2 # ABSTRACT: Header access on a PSGI environment, shaped like a Net::Async::HTTP::Server request
3 1 our $VERSION = '1.103';
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7  
8 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
Pod documented
9 0 my ($class, $env) = @_;
10 0 return bless { env => $env }, $class;
11 }
12  
13  
14 0 ▶sub path { $_[0]{env}{PATH_INFO} // '/' }
Subroutine path: not called CC=2 SCAR=17.9
Pod documented
Condition0%0/2
$_[0]{"env"}{"PATH_INFO"} // "/"
l!l
00
MC/DC0%0/1
$_[0]{"env"}{"PATH_INFO"} // "/"
$_[0]{"env"}{"PATH_INFO"}
Truth table0%0/2
A
A= $_[0]{"env"}{"PATH_INFO"}
Aresult
11
00
15  
16  
17 0 ▶sub header {
Subroutine header: not called CC=1 SCAR=6.9
Pod documented
18 0 my ($self, $name) = @_;
19 0 ( my $key = uc $name ) =~ tr/-/_/;
20 0 return $self->{env}{"HTTP_$key"};
21 }
22  
23  
24 # The request headers as [ name, value ] pairs, like
25 # Net::Async::HTTP::Server::Request->headers. PSGI keeps only the CGI form
26 # of a header name, so it comes back lower-cased with dashes (x-api-key).
27 0 ▶sub headers {
Subroutine headers: not called CC=4 SCAR=30.0
Pod documented
28 0 my ($self) = @_;
29 0 my $env = $self->{env};
30 0 my @pairs;
31 0 for my $key ( sort keys %$env ) {
32 0 ▶ my $name = $key =~ /\AHTTP_(.+)\z/ ? $1
Branch: 2 branches
BranchTrueFalseTotal
$key =~ /\AHTTP_(.+)\z/ ? : 0 0 0
$key =~ /\A(CONTENT_TYPE)\z/ ? : 0 0 0
33 : $key =~ /\A(CONTENT_TYPE)\z/ ? $1 : next;
34 0 ( $name = lc $name ) =~ tr/_/-/;
35 0 push @pairs, [ $name, $env->{$key} ];
36 }
37 0 return @pairs;
38 }
39  
40  
41 1 1;
42  
43 __END__
« blib/lib/Langertha/Knarr/Image.pm ↑ Summary blib/lib/Langertha/Knarr/Protocol.pm »