}
# 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' )
--- /dev/null
+#!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;
+
$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) );