line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catalyst::Response::Writer; |
2
|
167
|
|
|
167
|
|
2257
|
use strict; |
|
167
|
|
|
|
|
463
|
|
|
167
|
|
|
|
|
5374
|
|
3
|
167
|
|
|
167
|
|
1060
|
use warnings; |
|
167
|
|
|
|
|
505
|
|
|
167
|
|
|
|
|
28526
|
|
4
|
|
|
|
|
|
|
|
5
|
7
|
|
|
7
|
1
|
146
|
sub write { shift->{_writer}->write(@_) } |
6
|
5
|
|
|
5
|
1
|
943
|
sub close { shift->{_writer}->close } |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub write_encoded { |
9
|
1
|
|
|
1
|
1
|
11
|
my ($self, $line) = @_; |
10
|
1
|
50
|
33
|
|
|
20
|
if((my $enc = $self->{_context}->encoding) && $self->{_requires_encoding}) { |
11
|
|
|
|
|
|
|
# Not going to worry about CHECK arg since Unicode always croaks I think - jnap |
12
|
1
|
|
|
|
|
6
|
$line = $enc->encode($line); |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
1
|
|
|
|
|
12
|
$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
|
|
|
|
|
|
|
1; |