that sounds about right. here is a proposed patch:<div><br></div><div><span class="Apple-style-span" style="font-family: 'Times New Roman'; font-size: medium; "><pre style="color: rgb(0, 0, 0); background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(240, 240, 240); background-position: initial initial; background-repeat: initial initial; ">
diff --git a/lib/Catalyst/Action/Serialize.pm b/lib/Catalyst/Action/Serialize.pm
index 29ee605..27f00a4 100644
--- a/lib/Catalyst/Action/Serialize.pm
+++ b/lib/Catalyst/Action/Serialize.pm
@@ -23,7 +23,7 @@ sub execute {
$self->maybe::next::method(@_);
return 1 if $c->req->method eq 'HEAD';
- return 1 if length( $c->response->body );
+ return 1 if defined $c->response->body && length( $c->response->body );
return 1 if scalar @{ $c->error };
return 1 if $c->response->status =~ /^(?:204)$/;
diff --git a/t/catalyst-action-serialize.t b/t/catalyst-action-serialize.t
index 78ce12b..43d793d 100644
--- a/t/catalyst-action-serialize.t
+++ b/t/catalyst-action-serialize.t
@@ -1,6 +1,6 @@
use strict;
use warnings;
-use Test::More tests => 9;
+use Test::More tests => 11;
use Data::Serializer;
use FindBin;
@@ -35,4 +35,8 @@ $res2 = request($t->get(url => '/serialize/test_second'));
ok( $res2->is_success, 'request succeeded (deprecated config)' );
is( $res2->content, "{'lou' => 'is my cat'}", "request returned proper data");
+my $emptyres = request($t->get(url => '/serialize/empty'));
+is $emptyres->content, '';
+ok !$emptyres->header('Content-Length');
+
1;
diff --git a/t/lib/Test/Catalyst/Action/REST/Controller/Serialize.pm b/t/lib/Test/Catalyst/Action/REST/Controller/Serialize.pm
index 9d358c4..63cba8f 100644
--- a/t/lib/Test/Catalyst/Action/REST/Controller/Serialize.pm
+++ b/t/lib/Test/Catalyst/Action/REST/Controller/Serialize.pm
@@ -32,4 +32,8 @@ sub test_second :Local :ActionClass('Serialize') {
};
}
+sub empty :Local :ActionClass('Serialize') {
+ return undef;
+}
+
1;</pre><pre style="color: rgb(0, 0, 0); background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(240, 240, 240); background-position: initial initial; background-repeat: initial initial; ">
<br></pre><pre style="color: rgb(0, 0, 0); background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(240, 240, 240); background-position: initial initial; background-repeat: initial initial; ">
Justin</pre></span><br><div class="gmail_quote">On Thu, Jan 6, 2011 at 3:17 PM, Chad House <span dir="ltr"><<a href="mailto:chadh@pobox.com">chadh@pobox.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Testing out Catalyst::Runtime 5.80030, I noticed<br>
Catalyst::Action::Serialize (0.87) complaining about "Use of<br>
uninitialized value in length" -- it's testing the length of<br>
$c->response->body, which can now be undefined I gather.<br>
<br>
Cheers,<br>
<br>
Chad<br>
<br>
_______________________________________________<br>
List: <a href="mailto:Catalyst@lists.scsys.co.uk">Catalyst@lists.scsys.co.uk</a><br>
Listinfo: <a href="http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst" target="_blank">http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst</a><br>
Searchable archive: <a href="http://www.mail-archive.com/catalyst@lists.scsys.co.uk/" target="_blank">http://www.mail-archive.com/catalyst@lists.scsys.co.uk/</a><br>
Dev site: <a href="http://dev.catalyst.perl.org/" target="_blank">http://dev.catalyst.perl.org/</a><br>
</blockquote></div><br></div>