File Coverage

blib/lib/Catalyst/Response/Writer.pm
Criterion Covered Total %
statement 6 6 100.0
branch 1 2 50.0
condition 1 3 33.3
subroutine 3 3 100.0
pod 3 3 100.0
total 14 17 82.3


line stmt bran cond sub pod time code
1              
2              
3 7     7 1 113 my ($self, $line) = @_;
4 5     5 1 978 if((my $enc = $self->{_context}->encoding) && $self->{_requires_encoding}) {
5             # Not going to worry about CHECK arg since Unicode always croaks I think - jnap
6             $line = $enc->encode($line);
7 1     1 1 9 }
8 1 50 33     25  
9             $self->write($line);
10 1         10 }
11              
12             =head1 NAME
13 1         5  
14             Catalyst::Response::Writer - Proxy over the PSGI Writer
15              
16             =head1 SYNOPSIS
17              
18             sub myaction : Path {
19             my ($self, $c) = @_;
20             my $w = $c->response->writer_fh;
21              
22             $w->write("hello world");
23             $w->close;
24             }
25              
26             =head1 DESCRIPTION
27              
28             This wraps the PSGI writer (see L<PSGI.pod\Delayed-Response-and-Streaming-Body>)
29             for more. We wrap this object so we can provide some additional methods that
30             make sense from inside L<Catalyst>
31              
32             =head1 METHODS
33              
34             This class does the following methods
35              
36             =head2 write
37              
38             =head2 close
39              
40             These delegate to the underlying L<PSGI> writer object
41              
42             =head2 write_encoded
43              
44             If the application defines a response encoding (default is UTF8) and the
45             content type is a type that needs to be encoded (text types like HTML or XML and
46             Javascript) we first encode the line you want to write. This is probably the
47             thing you want to always do. If you use the L<\write> method directly you will
48             need to handle your own encoding.
49              
50             =head1 AUTHORS
51              
52             Catalyst Contributors, see Catalyst.pm
53              
54             =head1 COPYRIGHT
55              
56             This library is free software. You can redistribute it and/or modify
57             it under the same terms as Perl itself.
58              
59             =cut
60              
61             1;