blib/lib/HTTP/Response/CGI.pm

filter: Statementstmt 97.0% 33 / 34 Branchbran 64.2% 9 / 14 Conditioncond 50.0% 3 / 6 MC/DCmcdc 25.0% 1 / 4 Subroutinesub 100% 5 / 5 Podpod 100% 2 / 2 totaltotal 81.5% 53 / 65 CC 10 SCAR 21.1
CC
10
Cov
83%
parse
11.1
BEGIN
1.0
BEGIN
1.0
CRAP 8.2
↑ Summary
1 package HTTP::Response::CGI;
2 4 ▶use base 'HTTP::Response';
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 4 $VERSION = "1.0";
5  
6 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9  
10  
11 sub new
12 1 ▶{
Subroutine new: called CC=1 SCAR=0.0
Pod documented
13 1 my $class = shift;
14 1 my $self = $class->SUPER::new(@_);
15 1 $self;
16 }
17  
18  
19 sub parse
20 5 ▶{
Subroutine parse: called CC=10 SCAR=24.1
Pod documented
21 5 my($class, $str) = @_;
22 # borrowed from HTML::Response
23 5 my $status_line;
24 5 ▶ if ($str =~ m/^(.*)\n/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($str =~ /^(.*)\n/) { } 5 0 5
25 5 $status_line = $1;
26 }
27 else {
28 0 $status_line = $str;
29 }
30  
31 5 my $self = $class->SUPER::parse($str);
32  
33 5 ▶ if (!$self->protocol || $self->protocol =~ /^HTTP\/[\d\.]+/) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->protocol or $self->protocol =~ m[^HTTP/[\d\.]+]) { } 1 4 5
Condition66%2/3
not $self->protocol or $self->protocol =~ m[^HTTP/[\d\.]+]
l!l&&r!l&&!r
014
MC/DC50%1/2
not $self->protocol or $self->protocol =~ m[^HTTP/[\d\.]+]
not $self->protocol $self->protocol =~ m[^HTTP/[\d\.]+]
Truth table66%2/3
not(A) or B
A= not $self->protocolB= $self->protocol =~ m[^HTTP/[\d\.]+]
ABresult
1X1
011
000
34 # Everything was already set correctly by SUPER::parse().
35 # This may not be CGI output.
36 } else {
37 # Parsed the $status_line "incorrectly".
38
39 # If there was a header on the first line, it will get snarfed into
40 # protocol()/code().
41 # Re-parse that header out here.
42 4 my ($header, $value) = $status_line =~ /^([^:]+):\s*(.+)$/;
43 4 ▶ if ($header && $value) {
Branch: 1 branch
BranchTrueFalseTotal
if ($header and $value) 4 0 4
Condition33%1/3
$header and $value
!ll&&!rl&&r
004
MC/DC0%0/2
$header and $value
$header $value
Truth table33%1/3
A and B
A= $headerB= $value
ABresult
0X0
100
111
44 # remove carriage return, if it exists.
45 4 ▶ $value =~ s/\r$// if $value;
Branch: 1 branch
BranchTrueFalseTotal
if $value 4 0 4
46 4 $self->header($header => $value);
47 }
48  
49 # if headers contain a Status: line, modify that into an HTTP header.
50 4 ▶ if ($self->header('Status')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->header('Status')) { } 1 3 4
51 # case: the CGI has set an explict Status:
52 1 my ($code, $message) = split(' ', $self->header('Status'), 2);
53 1 $self->protocol(undef);
54 1 ▶ $self->code($code) if defined($code);
Branch: 1 branch
BranchTrueFalseTotal
if defined $code 1 0 1
55 1 ▶ $self->message($message) if defined($message);
Branch: 1 branch
BranchTrueFalseTotal
if defined $message 1 0 1
56 } else {
57 # case: the CGI has not set an explict Status:
58 # Assume "200 OK".
59 3 $self->protocol(undef);
60 3 $self->code('200');
61 3 $self->message('OK');
62 }
63 }
64  
65 5 $self;
66 }
67  
68  
69 4 1;
70  
71  
72 __END__
↑ Summary