update distar url
[catagits/Catalyst-Runtime.git] / lib / Catalyst / Response / Writer.pm
CommitLineData
e8361cf8 1package Catalyst::Response::Writer;
2
3sub write { shift->{_writer}->write(@_) }
4sub close { shift->{_writer}->close }
5
6sub write_encoded {
7 my ($self, $line) = @_;
688e2420 8 if((my $enc = $self->{_context}->encoding) && $self->{_requires_encoding}) {
e8361cf8 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
fe16aca1 16=head1 NAME
e8361cf8 17
18Catalyst::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
32This wraps the PSGI writer (see L<PSGI.pod\Delayed-Response-and-Streaming-Body>)
33for more. We wrap this object so we can provide some additional methods that
34make sense from inside L<Catalyst>
35
36=head1 METHODS
37
38This class does the following methods
39
40=head2 write
41
42=head2 close
43
44These delegate to the underlying L<PSGI> writer object
45
46=head2 write_encoded
47
88e5a8b0 48If the application defines a response encoding (default is UTF8) and the
e8361cf8 49content type is a type that needs to be encoded (text types like HTML or XML and
50Javascript) we first encode the line you want to write. This is probably the
51thing you want to always do. If you use the L<\write> method directly you will
52need to handle your own encoding.
53
54=head1 AUTHORS
55
56Catalyst Contributors, see Catalyst.pm
57
58=head1 COPYRIGHT
59
60This library is free software. You can redistribute it and/or modify
61it under the same terms as Perl itself.
62
63=cut
64
651;