Skip Menu |

This queue is for tickets about the Catalyst-Action-REST CPAN distribution.

Report information
The Basics
Id: 51769
Status: open
Priority: 0/
Queue: Catalyst-Action-REST

People
Owner: Nobody in particular
Requestors: gerv-cpan [...] gerv.net
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.78
Fixed in: (no value)



Subject: Catalyst::Action::Serialize::JSON does not deal with empty bodies
If $c->stash->{'rest'} is undef, Catalyst::Action::Serialize::JSON barfs. This can happen e.g. on an OPTIONS request, which is supposed to have an empty body - and, in fact, does happen using Catalyst::Action::REST's default OPTIONS handler when using application/json! In other words, the default OPTIONS handler doesn't work with application/json. The right fix, I think, is to have Catalyst::Action::Serialize::JSON return "" if $c->stash->{$stash_key} is undef. I've worked around this by putting: sub end : ActionClass('Serialize') { my ($self, $c) = @_; # Catalyst::Action::Serialize::JSON doesn't deal well with empty bodies # You can get one of these with e.g. OPTIONS requests if (!defined($c->stash->{'rest'}) { $c->stash->{'rest'} = {}; } } in each of my Controller classes, but that's not great. Gerv
Committed a failing test for this as 3f92b24