use Catalyst::Request::Upload;
use Catalyst::Response;
use Catalyst::Utils;
+use File::stat;
use NEXT;
use Text::SimpleTable;
use Path::Class;
require Module::Pluggable::Fast;
# Helper script generation
-our $CATALYST_SCRIPT_GEN = 23;
+our $CATALYST_SCRIPT_GEN = 24;
__PACKAGE__->mk_classdata($_)
for qw/components arguments dispatcher engine log dispatcher_class
__PACKAGE__->request_class('Catalyst::Request');
__PACKAGE__->response_class('Catalyst::Response');
-our $VERSION = '5.61';
+our $VERSION = '5.62';
sub import {
my ( $class, @arguments ) = @_;
sub controller {
my ( $c, $name ) = @_;
my $controller = $c->comp("Controller::$name");
- return $controller if $controller;
+ return $controller if defined $controller;
return $c->comp("C::$name");
}
sub model {
my ( $c, $name ) = @_;
my $model = $c->comp("Model::$name");
- return $model if $model;
+ return $model if defined $model;
return $c->comp("M::$name");
}
sub view {
my ( $c, $name ) = @_;
my $view = $c->comp("View::$name");
- return $view if $view;
+ return $view if defined $view;
return $c->comp("V::$name");
}
# Content-Length
if ( $c->response->body && !$c->response->content_length ) {
- $c->response->content_length( bytes::length( $c->response->body ) );
+ # get the length from a filehandle
+ if ( ref $c->response->body && $c->response->body->can('read') ) {
+ if ( my $stat = stat $c->response->body ) {
+ $c->response->content_length( $stat->size );
+ }
+ else {
+ $c->log->warn(
+ 'Serving filehandle without a content-length' );
+ }
+ }
+ else {
+ $c->response->content_length(
+ bytes::length( $c->response->body ) );
+ }
}
# Errors