# This file documents the revision history for Perl extension Catalyst.
+ - Fix return value of $c->req->body, which delegates to the body
+ method on the HTTP::Body of the request (t0m)
+ - Test for this (t0m)
- Fix calling $c->req->body from inside an overridden prepare_action
method in a plugin, as used by Catalyst::Plugin::Server (t0m)
- Test for this (t0m)
has _body => (
is => 'rw',
- accessor => 'body',
);
-
-before body => sub {
- my ($self) = @_;
+# Eugh, ugly. Should just be able to rename accessor methods to 'body'
+# and provide a custom reader..
+sub body {
+ my $self = shift;
$self->_context->prepare_body();
-};
+ $self->_body(@_) if scalar @_;
+ return blessed $self->_body ? $self->_body->body : $self->_body;
+}
has hostname => (
is => 'rw',
#!perl
-
use strict;
use warnings;
use FindBin;
use lib "$FindBin::Bin/../lib";
-use Test::More tests => 21;
+use Test::More tests => 23;
use Catalyst::Test 'TestApp';
use Catalyst::Request;
isa_ok( $creq, 'Catalyst::Request' );
is( $creq->method, 'POST', 'Catalyst::Request method' );
is( $creq->content_type, 'text/plain', 'Catalyst::Request Content-Type' );
+ is( $creq->{__body_type}, 'File::Temp' );
is( $creq->content_length, $request->content_length,
'Catalyst::Request Content-Length' );
}
isa_ok( $creq, 'Catalyst::Request' );
is( $creq->method, 'POST', 'Catalyst::Request method' );
is( $creq->content_type, 'text/plain', 'Catalyst::Request Content-Type' );
+ is( $creq->{__body_type}, 'File::Temp' );
is( $creq->content_length, $request->content_length,
'Catalyst::Request Content-Length' );
}
use base 'Catalyst::View';
use Data::Dumper ();
-use Scalar::Util qw(weaken);
+use Scalar::Util qw(blessed weaken);
sub dump {
my ( $self, $reference ) = @_;
# Force processing of on-demand data
$c->prepare_body;
- # Remove context from reference if needed
- my $context = delete $reference->{_context};
-
# Remove body from reference if needed
+ $reference->{__body_type} = blessed $reference->body
+ if (blessed $reference->{_body});
my $body = delete $reference->{_body};
+ # Remove context from reference if needed
+ my $context = delete $reference->{_context};
+
if ( my $output =
$self->dump( $reference || $c->stash->{dump} || $c->stash ) )
{
weaken( $reference->{_context} );
# Repair body
+ delete $reference->{__body_type};
$reference->{_body} = $body;
return 1;