lib/Catalyst/Response/Writer.pm

filter: Statementstmt 100% 13 / 13 Branchbran 50.0% 1 / 2 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 5 / 5 Podpod 100% 3 / 3 totaltotal 82.1% 23 / 28 CC 3 SCAR 6.9
CC
3
Cov
83%
write_encoded
3.3
BEGIN
1.0
BEGIN
1.0
CRAP 2.0
« lib/Catalyst/ActionRole/HTTPMethods.pm ↑ Summary lib/Catalyst/Script/Create.pm »
1 package Catalyst::Response::Writer;
2 166 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 166 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 7 ▶sub write { shift->{_writer}->write(@_) }
Subroutine write: called CC=1 SCAR=0.0
Pod documented
6 5 ▶sub close { shift->{_writer}->close }
Subroutine close: called CC=1 SCAR=0.0
Pod documented
7  
8 1 ▶sub write_encoded {
Subroutine write_encoded: called CC=3 SCAR=12.0
Pod documented
9 1 my ($self, $line) = @_;
10 1 ▶ if((my $enc = $self->{_context}->encoding) && $self->{_requires_encoding}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $enc = $self->{"_context"}->encoding and $self->{"_requires_encoding"}) 1 0 1
Condition33%1/3
my $enc = $self->{"_context"}->encoding and $self->{"_requires_encoding"}
!ll&&!rl&&r
001
MC/DC0%0/2
my $enc = $self->{"_context"}->encoding and $self->{"_requires_encoding"}
my $enc = $self->{"_context"}->encoding $self->{"_requires_encoding"}
Truth table33%1/3
A and B
A= my $enc = $self->{"_context"}->encodingB= $self->{"_requires_encoding"}
ABresult
0X0
100
111
11 # Not going to worry about CHECK arg since Unicode always croaks I think - jnap
12 1 $line = $enc->encode($line);
13 }
14  
15 1 $self->write($line);
16 }
17  
18 =head1 NAME
19  
20 Catalyst::Response::Writer - Proxy over the PSGI Writer
21  
22 =head1 SYNOPSIS
23  
24 sub myaction : Path {
25 my ($self, $c) = @_;
26 my $w = $c->response->writer_fh;
27  
28 $w->write("hello world");
29 $w->close;
30 }
31  
32 =head1 DESCRIPTION
33  
34 This wraps the PSGI writer (see L<PSGI.pod\Delayed-Response-and-Streaming-Body>)
35 for more. We wrap this object so we can provide some additional methods that
36 make sense from inside L<Catalyst>
37  
38 =head1 METHODS
39  
40 This class does the following methods
41  
42 =head2 write
43  
44 =head2 close
45  
46 These delegate to the underlying L<PSGI> writer object
47  
48 =head2 write_encoded
49  
50 If the application defines a response encoding (default is UTF8) and the
51 content type is a type that needs to be encoded (text types like HTML or XML and
52 Javascript) we first encode the line you want to write. This is probably the
53 thing you want to always do. If you use the L<\write> method directly you will
54 need to handle your own encoding.
55  
56 =head1 AUTHORS
57  
58 Catalyst Contributors, see Catalyst.pm
59  
60 =head1 COPYRIGHT
61  
62 This library is free software. You can redistribute it and/or modify
63 it under the same terms as Perl itself.
64  
65 =cut
66  
67 166 1;
« lib/Catalyst/ActionRole/HTTPMethods.pm ↑ Summary lib/Catalyst/Script/Create.pm »