=head2 encoding
-Sets or gets the application encoding.
+Sets or gets the application encoding. Setting encoding takes either an
+Encoding object or a string that we try to resolve via L<Encode::find_encoding>.
+
+You would expect to get the encoding object back if you attempt to set it. If
+there is a failure you will get undef returned and an error message in the log.
=cut
if(blessed $c) {
$c->encoding(undef);
} else {
- $c->debug->error("You can't clear encoding on the application");
+ $c->log->error("You can't clear encoding on the application");
}
}
my $encoding;
if ( scalar @_ ) {
+
+ # Don't let one change this once we are too far into the response
+ if(blessed $c && $c->res->finalized_headers) {
+ Carp::croak("You may not change the encoding once the headers are finalized");
+ return;
+ }
+
# Let it be set to undef
if (my $wanted = shift) {
$encoding = Encode::find_encoding($wanted)