GX/HTTP/Response.pm

filter: Statementstmt 95.4% 42 / 44 Branchbran 60.0% 6 / 10 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 8 / 8 Podpod 100% 2 / 2 totaltotal 85.5% 59 / 69 CC 7 SCAR 11.0
CC
7
Cov
86%
status_line
5.3
print_to
3.2
BEGIN
1.0
CRAP 3.0
« GX/Class/Singleton.pm ↑ Summary GX/Exception/StackTrace.pm »
1 # ----------------------------------------------------------------------------------------------------------------------
2 # GX Framework (c) 2009-2011 Jörg A. Uzarek <uzarek@runlevelnull.de>
3 # File: GX/HTTP/Response.pm
4 # ----------------------------------------------------------------------------------------------------------------------
5  
6 package GX::HTTP::Response;
7  
8 9 ▶use GX::Exception;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 9 ▶use GX::HTTP::Constants qw( CRLF );
Subroutine BEGIN: called CC=1 SCAR=0.0
10 9 ▶use GX::HTTP::Response::Headers;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 9 ▶use GX::HTTP::Status;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13  
14 # ----------------------------------------------------------------------------------------------------------------------
15 # Class setup
16 # ----------------------------------------------------------------------------------------------------------------------
17  
18 9 ▶use GX::Class;
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 9 extends 'GX::HTTP::Message';
21  
22 9 has 'status' => (
23 isa => 'Scalar'
24 );
25  
26 9 has 'status_reason' => (
27 isa => 'Scalar'
28 );
29  
30 9 build;
31  
32  
33 # ----------------------------------------------------------------------------------------------------------------------
34 # Public methods
35 # ----------------------------------------------------------------------------------------------------------------------
36  
37 8 ▶sub print_to {
Subroutine print_to: called CC=3 SCAR=11.6
Pod documented
38  
39 8 my $self = shift;
40 8 my $handle = shift;
41  
42 8 my $result = eval {
43 8 ▶ $handle->print( $self->status_line, CRLF ) && $self->SUPER::print_to( $handle );
Condition33%1/3
$handle->print($self->status_line, "\r\n") && $self->SUPER::print_to($handle)
!ll&&!rl&&r
008
MC/DC0%0/2
$handle->print($self->status_line, "\r\n") && $self->SUPER::print_to($handle)
$handle->print($self->status_line, "\r\n") $self->SUPER::print_to($handle)
Truth table33%1/3
A && B
A= $handle->print($self->status_line, "\r\n")B= $self->SUPER::print_to($handle)
ABresult
0X0
100
111
44 };
45  
46 8 ▶ complain $@ if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 8 8
47  
48 8 return $result;
49  
50 }
51  
52 11 ▶sub status_line {
Subroutine status_line: called CC=5 SCAR=16.7
Pod documented
53  
54 11 my $self = shift;
55  
56 11 my $protocol = $self->protocol;
57  
58 11 ▶ if ( ! defined $protocol ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $protocol) 0 11 11
59 0 complain "Undefined protocol version";
60 }
61  
62 11 my $status = $self->status;
63  
64 11 ▶ if ( ! defined $status ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $status) 0 11 11
65 0 complain "Undefined response status";
66 }
67  
68 11 my $line = $protocol . ' ' . $status;
69  
70 11 my $reason = $self->status_reason;
71  
72 11 ▶ if ( ! defined $reason ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $reason) 9 2 11
73 9 $reason = GX::HTTP::Status::reason_phrase( $status );
74 }
75  
76 11 ▶ if ( defined $reason ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $reason) 11 0 11
77 11 $line .= ' '. $reason;
78 }
79  
80 11 return $line;
81  
82 }
83  
84 {
85  
86 9 for ( qw(
87 Location
88 ) ) {
89 9 __PACKAGE__->_install_header_accessor( $_ );
90 }
91  
92 }
93  
94  
95 # ----------------------------------------------------------------------------------------------------------------------
96 # Private methods
97 # ----------------------------------------------------------------------------------------------------------------------
98  
99 6 ▶sub _initialize_headers {
Subroutine _initialize_headers: called CC=1 SCAR=0.0
100  
101 6 return GX::HTTP::Response::Headers->new;
102  
103 }
104  
105  
106 9 1;
107  
108 __END__
« GX/Class/Singleton.pm ↑ Summary GX/Exception/StackTrace.pm »