# This file documents the revision history for Perl extension Catalyst.
+5.90082 - 2014-01-10
+ - Fixed a regression created in $response->from_psgi_response and test case
+ to prevent it happening again.
+
5.90081 - 2014-01-10
- created class attribute 'finalized_default_middleware' which determines
if the default middleware has been added to the stack yet or not. This
__PACKAGE__->_encode_check(Encode::FB_CROAK | Encode::LEAVE_SRC);
# Remember to update this in Catalyst::Runtime as well!
-our $VERSION = '5.90081';
+our $VERSION = '5.90082';
$VERSION = eval $VERSION if $VERSION =~ /_/; # numify for warning-free dev releases
sub import {
my ($status, $headers, $body) = @$psgi_res;
$self->status($status);
$self->headers(HTTP::Headers->new(@$headers));
- $self->body(join('', @$body));
+ # Can be arrayref or filehandle...
+ if(defined $body) { # probably paranoia
+ ref $body eq 'ARRAY' ? $self->body(join('', @$body)) : $self->body($body);
+ }
} elsif(ref $psgi_res eq 'CODE') {
$psgi_res->(sub {
my $response = shift;
$self->status($status);
$self->headers(HTTP::Headers->new(@$headers));
if(defined $maybe_body) {
- $self->body(join('', @$maybe_body));
+ # Can be arrayref or filehandle...
+ ref $maybe_body eq 'ARRAY' ? $self->body(join('', @$maybe_body)) : $self->body($maybe_body);
} else {
return $self->write_fh;
}
# Remember to update this in Catalyst as well!
-our $VERSION = '5.90081';
+our $VERSION = '5.90082';
$VERSION = eval $VERSION if $VERSION =~ /_/; # numify for warning-free dev releases
=head1 NAME
$psgi_app->($env));
}
+ sub filehandle :Local {
+ my ($self, $c, $arg) = @_;
+ my $path = File::Spec->catfile('t', 'utf8.txt');
+ open(my $fh, '<', $path) || die "trouble: $!";
+ $c->res->from_psgi_response([200, ['Content-Type'=>'text/html'], $fh]);
+ }
+
+ sub direct :Local {
+ my ($self, $c, $arg) = @_;
+ $c->res->from_psgi_response([200, ['Content-Type'=>'text/html'], ["hello","world"]]);
+ }
+
package MyApp::Controller::User;
$INC{'MyApp/Controller/User.pm'} = __FILE__;
is_deeply $c->req->args, [111];
}
+{
+ use utf8;
+ use Encode;
+ my ($res, $c) = ctx_request('/docs/filehandle');
+ is Encode::decode_utf8($res->content), "<p>This is stream_body_fh action ♥</p>\n";
+}
+
+{
+ my ($res, $c) = ctx_request('/docs/direct');
+ is $res->content, "helloworld";
+}
+
done_testing();