From: Jesse Sheidlower Date: Wed, 22 Oct 2014 16:04:00 +0000 (-0500) Subject: Allow redirections like ::RenderView X-Git-Tag: v1.17~2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ffef349776f351e486c641f21ea1941fe30ca8da;p=catagits%2FCatalyst-Action-REST.git Allow redirections like ::RenderView --- diff --git a/Changes b/Changes index c174799..72f0f22 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,8 @@ Revision history for {{$dist->name}} {{$NEXT}} + * Make 3xx status codes skip serialization when there is no data to serialize + (Thanks Jesse Sheidlower!) 1.16 2014-09-12 13:21:43-05:00 America/Chicago * Switch from JSON to JSON::MaybeXS to get a better choice of JSON parsers. diff --git a/lib/Catalyst/Action/Serialize.pm b/lib/Catalyst/Action/Serialize.pm index b310612..fd36878 100644 --- a/lib/Catalyst/Action/Serialize.pm +++ b/lib/Catalyst/Action/Serialize.pm @@ -26,6 +26,15 @@ sub execute { return 1 if defined $c->stash->{current_view}; return 1 if defined $c->stash->{current_view_instance}; + # on 3xx responses, serialize if there's something to + # serialize, no-op if not + my $stash_key = ( + $controller->{'serialize'} ? + $controller->{'serialize'}->{'stash_key'} : + $controller->{'stash_key'} + ) || 'rest'; + return 1 if $c->response->status =~ /^(?:3\d\d)$/ && ! defined $c->stash->{$stash_key}; + my ( $sclass, $sarg, $content_type ) = $self->_load_content_plugins( "Catalyst::Action::Serialize", $controller, $c );