[Catalyst-commits] r8959 - in Catalyst-Runtime/5.80/trunk: .
lib/Catalyst t/aggregate t/lib/TestApp/View
t0m at dev.catalyst.perl.org
t0m at dev.catalyst.perl.org
Sat Dec 27 19:44:45 GMT 2008
Author: t0m
Date: 2008-12-27 19:44:45 +0000 (Sat, 27 Dec 2008)
New Revision: 8959
Modified:
Catalyst-Runtime/5.80/trunk/Changes
Catalyst-Runtime/5.80/trunk/lib/Catalyst/Request.pm
Catalyst-Runtime/5.80/trunk/t/aggregate/live_engine_request_body.t
Catalyst-Runtime/5.80/trunk/t/lib/TestApp/View/Dump.pm
Log:
Fix the return value of Catalyst::Request's body method + tests.
Modified: Catalyst-Runtime/5.80/trunk/Changes
===================================================================
--- Catalyst-Runtime/5.80/trunk/Changes 2008-12-27 18:08:02 UTC (rev 8958)
+++ Catalyst-Runtime/5.80/trunk/Changes 2008-12-27 19:44:45 UTC (rev 8959)
@@ -1,5 +1,8 @@
# 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)
Modified: Catalyst-Runtime/5.80/trunk/lib/Catalyst/Request.pm
===================================================================
--- Catalyst-Runtime/5.80/trunk/lib/Catalyst/Request.pm 2008-12-27 18:08:02 UTC (rev 8958)
+++ Catalyst-Runtime/5.80/trunk/lib/Catalyst/Request.pm 2008-12-27 19:44:45 UTC (rev 8959)
@@ -98,13 +98,15 @@
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',
Modified: Catalyst-Runtime/5.80/trunk/t/aggregate/live_engine_request_body.t
===================================================================
--- Catalyst-Runtime/5.80/trunk/t/aggregate/live_engine_request_body.t 2008-12-27 18:08:02 UTC (rev 8958)
+++ Catalyst-Runtime/5.80/trunk/t/aggregate/live_engine_request_body.t 2008-12-27 19:44:45 UTC (rev 8959)
@@ -1,12 +1,11 @@
#!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;
@@ -39,6 +38,7 @@
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' );
}
@@ -72,6 +72,7 @@
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' );
}
Modified: Catalyst-Runtime/5.80/trunk/t/lib/TestApp/View/Dump.pm
===================================================================
--- Catalyst-Runtime/5.80/trunk/t/lib/TestApp/View/Dump.pm 2008-12-27 18:08:02 UTC (rev 8958)
+++ Catalyst-Runtime/5.80/trunk/t/lib/TestApp/View/Dump.pm 2008-12-27 19:44:45 UTC (rev 8959)
@@ -4,7 +4,7 @@
use base 'Catalyst::View';
use Data::Dumper ();
-use Scalar::Util qw(weaken);
+use Scalar::Util qw(blessed weaken);
sub dump {
my ( $self, $reference ) = @_;
@@ -28,12 +28,14 @@
# Force processing of on-demand data
$c->prepare_body;
+ # 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};
- # Remove body from reference if needed
- my $body = delete $reference->{_body};
-
if ( my $output =
$self->dump( $reference || $c->stash->{dump} || $c->stash ) )
{
@@ -46,6 +48,7 @@
weaken( $reference->{_context} );
# Repair body
+ delete $reference->{__body_type};
$reference->{_body} = $body;
return 1;
More information about the Catalyst-commits
mailing list