X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=blobdiff_plain;f=lib%2FCatalyst.pm;h=ceb238e1ca18b83ff520276993c3e1c9c6f89727;hp=a2555432ff61719f1cd36d6cb5c8bbc98970f8c7;hb=d91504e32dc14e87f6650b1835f1287cac40fe7e;hpb=566678d0245e49d7f2f1abce553b5bdb87879086 diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index a255543..ceb238e 100644 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -129,7 +129,7 @@ __PACKAGE__->stats_class('Catalyst::Stats'); __PACKAGE__->_encode_check(Encode::FB_CROAK | Encode::LEAVE_SRC); # Remember to update this in Catalyst::Runtime as well! -our $VERSION = '5.90079_006'; +our $VERSION = '5.90089_001'; $VERSION = eval $VERSION if $VERSION =~ /_/; # numify for warning-free dev releases sub import { @@ -1049,7 +1049,11 @@ Clears the encoding for the current context =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. + +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 @@ -1060,7 +1064,7 @@ sub clear_encoding { 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"); } } @@ -1069,6 +1073,13 @@ sub encoding { 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) @@ -3621,7 +3632,7 @@ sub default_data_handlers { return eval { local $/; $slurped = $fh->getline; - $parser->can("decode_json")->($slurped); + $parser->can("decode_json")->($slurped); # decode_json does utf8 decoding for us } || Catalyst::Exception->throw(sprintf "Error Parsing POST '%s', Error: %s", (defined($slurped) ? $slurped : 'undef') ,$@); }, };