[Catalyst-commits] r13865 - in Catalyst-Runtime/5.80/trunk: lib/Catalyst t/aggregate

t0m at dev.catalyst.perl.org t0m at dev.catalyst.perl.org
Thu Dec 16 22:51:52 GMT 2010


Author: t0m
Date: 2010-12-16 22:51:52 +0000 (Thu, 16 Dec 2010)
New Revision: 13865

Modified:
   Catalyst-Runtime/5.80/trunk/lib/Catalyst/Response.pm
   Catalyst-Runtime/5.80/trunk/t/aggregate/unit_response.t
Log:
Make response body able to be undef to allow RenderView to see 'defined but empty' body, allowing X-Sendfile to work nicer. Also removes horrible modifier code. win/win if it doesn't break anything else.

Modified: Catalyst-Runtime/5.80/trunk/lib/Catalyst/Response.pm
===================================================================
--- Catalyst-Runtime/5.80/trunk/lib/Catalyst/Response.pm	2010-12-16 22:10:51 UTC (rev 13864)
+++ Catalyst-Runtime/5.80/trunk/lib/Catalyst/Response.pm	2010-12-16 22:51:52 UTC (rev 13865)
@@ -6,14 +6,8 @@
 with 'MooseX::Emulate::Class::Accessor::Fast';
 
 has cookies   => (is => 'rw', default => sub { {} });
-has body      => (is => 'rw', default => '', lazy => 1, predicate => 'has_body',
-    clearer => '_clear_body'
-);
-after 'body' => sub { # If someone assigned undef, clear the body so we get ''
-    if (scalar(@_) == 2 && !defined($_[1])) {
-         $_[0]->_clear_body;
-    }
-};
+has body      => (is => 'rw', default => undef, lazy => 1, predicate => 'has_body');
+
 has location  => (is => 'rw');
 has status    => (is => 'rw', default => 200);
 has finalized_headers => (is => 'rw', default => 0);

Modified: Catalyst-Runtime/5.80/trunk/t/aggregate/unit_response.t
===================================================================
--- Catalyst-Runtime/5.80/trunk/t/aggregate/unit_response.t	2010-12-16 22:10:51 UTC (rev 13864)
+++ Catalyst-Runtime/5.80/trunk/t/aggregate/unit_response.t	2010-12-16 22:51:52 UTC (rev 13865)
@@ -1,8 +1,9 @@
 use strict;
 use warnings;
-use Test::More tests => 6;
+use Test::More;
 
 use_ok('Catalyst::Response');
+use_ok('Catalyst::Engine');
 
 my $res = Catalyst::Response->new;
 
@@ -12,7 +13,5 @@
 is($res->status, 500, 'code sets status');
 $res->status(501);
 is($res->code, 501, 'status sets code');
-is($res->body, '', "default response body ''");
-$res->body(undef);
-is($res->body, '', "response body '' after assigned undef");
 
+done_testing;




More information about the Catalyst-commits mailing list