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