On Fri, 7 Apr 2006 14:30:34 +0100, Carl wrote:

> On 07/04/06, ADSJ (Adam Sjøgren) <[EMAIL PROTECTED]> wrote:
>> -    return 1 if $c->response->body;
>> +    return 1 if length $c->response->body;

> That'll cause a warning whenever body is undefined.

I didn't see any warnings when I tried it, but that should not stand
in our way, so please find attached a patch, updated as you suggested,
and I have included a test as well.


  Best regards & thanks,

       Adam

-- 
                                                          Adam Sjøgren
                                                    [EMAIL PROTECTED]
diff -rc Catalyst-Plugin-DefaultEnd-0.06.orig/lib/Catalyst/Plugin/DefaultEnd.pm Catalyst-Plugin-DefaultEnd-0.06/lib/Catalyst/Plugin/DefaultEnd.pm
*** Catalyst-Plugin-DefaultEnd-0.06.orig/lib/Catalyst/Plugin/DefaultEnd.pm	2006-06-21 10:38:52.000000000 +0200
--- Catalyst-Plugin-DefaultEnd-0.06/lib/Catalyst/Plugin/DefaultEnd.pm	2006-06-21 10:32:39.000000000 +0200
***************
*** 43,49 ****
      unless ( $c->response->content_type ) {
          $c->response->content_type('text/html; charset=utf-8');
      }
!     return 1                                 if $c->response->body;
      return $c->forward( $c->config->{view} ) if $c->config->{view};
      my ($comp) = $c->comp( '^' . ref($c) . '::(V|View)::' );
      $c->forward( ref $comp );
--- 43,49 ----
      unless ( $c->response->content_type ) {
          $c->response->content_type('text/html; charset=utf-8');
      }
!     return 1                                 if defined $c->response->body && length $c->response->body;
      return $c->forward( $c->config->{view} ) if $c->config->{view};
      my ($comp) = $c->comp( '^' . ref($c) . '::(V|View)::' );
      $c->forward( ref $comp );
diff -rc Catalyst-Plugin-DefaultEnd-0.06.orig/t/04live.t Catalyst-Plugin-DefaultEnd-0.06/t/04live.t
*** Catalyst-Plugin-DefaultEnd-0.06.orig/t/04live.t	2006-06-21 10:38:52.000000000 +0200
--- Catalyst-Plugin-DefaultEnd-0.06/t/04live.t	2006-06-21 10:33:13.000000000 +0200
***************
*** 6,12 ****
  use FindBin;
  use lib "$FindBin::Bin/lib";
  
! use Test::More tests => 15;
  use Catalyst::Test 'TestApp';
  
  BEGIN {
--- 6,12 ----
  use FindBin;
  use lib "$FindBin::Bin/lib";
  
! use Test::More tests => 20;
  use Catalyst::Test 'TestApp';
  
  BEGIN {
***************
*** 70,73 ****
--- 70,87 ----
          is( $response->content, $expected, 'Content OK' );
      }
  
+     # test zero body
+     {
+         my $expected = '0';
+         my $request  =
+           HTTP::Request->new( GET => 'http://localhost:3000/test_zerobody' );
+ 
+         ok( my $response = request($request), 'Request' );
+         ok( $response->is_success, 'Response Successful 2xx' );
+         is( $response->header( 'Content-Type' ), 'text/html; charset=utf-8', 'Content Type' );
+         is( $response->code, 200, 'Response Code' );
+ 
+         is( $response->content, $expected, 'Content OK' );
+     }
+ 
  }
diff -rc Catalyst-Plugin-DefaultEnd-0.06.orig/t/lib/TestApp.pm Catalyst-Plugin-DefaultEnd-0.06/t/lib/TestApp.pm
*** Catalyst-Plugin-DefaultEnd-0.06.orig/t/lib/TestApp.pm	2006-06-21 10:38:52.000000000 +0200
--- Catalyst-Plugin-DefaultEnd-0.06/t/lib/TestApp.pm	2006-06-21 10:33:25.000000000 +0200
***************
*** 26,29 ****
      $c->res->body( 'Skipped View' );
  }
  
! 1;
\ No newline at end of file
--- 26,34 ----
      $c->res->body( 'Skipped View' );
  }
  
! sub test_zerobody : Global {
!     my ( $self, $c ) = @_;
!     $c->res->body( '0' );
! }
! 
! 1;
_______________________________________________
List: [email protected]
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/

Reply via email to