[Catalyst-commits] r13871 - in Catalyst-Runtime/5.80/trunk: lib t/aggregate t/lib/TestApp/Controller

t0m at dev.catalyst.perl.org t0m at dev.catalyst.perl.org
Fri Dec 17 00:44:53 GMT 2010


Author: t0m
Date: 2010-12-17 00:44:53 +0000 (Fri, 17 Dec 2010)
New Revision: 13871

Added:
   Catalyst-Runtime/5.80/trunk/t/aggregate/live_engine_response_emptybody.t
Modified:
   Catalyst-Runtime/5.80/trunk/lib/Catalyst.pm
   Catalyst-Runtime/5.80/trunk/t/lib/TestApp/Controller/Root.pm
Log:
Fix the case for body '0'

Modified: Catalyst-Runtime/5.80/trunk/lib/Catalyst.pm
===================================================================
--- Catalyst-Runtime/5.80/trunk/lib/Catalyst.pm	2010-12-16 23:10:49 UTC (rev 13870)
+++ Catalyst-Runtime/5.80/trunk/lib/Catalyst.pm	2010-12-17 00:44:53 UTC (rev 13871)
@@ -1857,7 +1857,7 @@
     }
 
     # Content-Length
-    if ( $response->body && !$response->content_length ) {
+    if ( defined $response->body && !$response->content_length ) {
 
         # get the length from a filehandle
         if ( blessed( $response->body ) && $response->body->can('read') || ref( $response->body ) eq 'GLOB' )

Added: Catalyst-Runtime/5.80/trunk/t/aggregate/live_engine_response_emptybody.t
===================================================================
--- Catalyst-Runtime/5.80/trunk/t/aggregate/live_engine_response_emptybody.t	                        (rev 0)
+++ Catalyst-Runtime/5.80/trunk/t/aggregate/live_engine_response_emptybody.t	2010-12-17 00:44:53 UTC (rev 13871)
@@ -0,0 +1,27 @@
+#!perl
+
+use strict;
+use warnings;
+
+use FindBin;
+use lib "$FindBin::Bin/../lib";
+
+use Test::More;
+use Catalyst::Test 'TestApp';
+
+# body '0'
+{
+    my $res = request('/zerobody');
+    is $res->content, '0';
+    is $res->header('Content-Length'), '1';
+}
+
+# body ''
+{
+    my $res = request('/emptybody');
+    is $res->content, '';
+    ok !$res->header('Content-Length');
+}
+
+done_testing;
+

Modified: Catalyst-Runtime/5.80/trunk/t/lib/TestApp/Controller/Root.pm
===================================================================
--- Catalyst-Runtime/5.80/trunk/t/lib/TestApp/Controller/Root.pm	2010-12-16 23:10:49 UTC (rev 13870)
+++ Catalyst-Runtime/5.80/trunk/t/lib/TestApp/Controller/Root.pm	2010-12-17 00:44:53 UTC (rev 13871)
@@ -14,6 +14,16 @@
     $c->forward('TestApp::View::Dump::Request');
 }
 
+sub zerobody : Local {
+    my ($self, $c) = @_;
+    $c->res->body('0');
+}
+
+sub emptybody : Local {
+    my ($self, $c) = @_;
+    $c->res->body('');
+}
+
 sub localregex : LocalRegex('^localregex$') {
     my ( $self, $c ) = @_;
     $c->res->header( 'X-Test-Class' => ref($self) );




More information about the Catalyst-commits mailing list