[Catalyst-commits] r14331 - in trunk/Catalyst-Plugin-SubRequest:
lib/Catalyst/Plugin t t/lib/TestApp/Controller
edenc at dev.catalyst.perl.org
edenc at dev.catalyst.perl.org
Thu Jul 19 03:39:54 GMT 2012
Author: edenc
Date: 2012-07-19 03:39:54 +0000 (Thu, 19 Jul 2012)
New Revision: 14331
Modified:
trunk/Catalyst-Plugin-SubRequest/lib/Catalyst/Plugin/SubRequest.pm
trunk/Catalyst-Plugin-SubRequest/t/02subreq.t
trunk/Catalyst-Plugin-SubRequest/t/lib/TestApp/Controller/Root.pm
Log:
parameters are now being properly passed to the sub request
Modified: trunk/Catalyst-Plugin-SubRequest/lib/Catalyst/Plugin/SubRequest.pm
===================================================================
--- trunk/Catalyst-Plugin-SubRequest/lib/Catalyst/Plugin/SubRequest.pm 2012-07-18 19:29:23 UTC (rev 14330)
+++ trunk/Catalyst-Plugin-SubRequest/lib/Catalyst/Plugin/SubRequest.pm 2012-07-19 03:39:54 UTC (rev 14331)
@@ -2,6 +2,7 @@
use strict;
use warnings;
+use Plack::Request;
our $VERSION = '0.18';
@@ -85,6 +86,10 @@
my ( $c, $path, $stash, $params ) = @_;
$stash ||= {};
my $env = $c->request->env;
+ my $req = Plack::Request->new($env);
+ my $uri = $req->uri;
+ $uri->query_form($params||{});
+ $env->{QUERY_STRING} = $uri->query||'';
local $env->{PATH_INFO} = $path;
local $env->{REQUEST_URI} = $env->{SCRIPT_NAME} . $path;
$env->{REQUEST_URI} =~ s|//|/|g;
Modified: trunk/Catalyst-Plugin-SubRequest/t/02subreq.t
===================================================================
--- trunk/Catalyst-Plugin-SubRequest/t/02subreq.t 2012-07-18 19:29:23 UTC (rev 14330)
+++ trunk/Catalyst-Plugin-SubRequest/t/02subreq.t 2012-07-19 03:39:54 UTC (rev 14331)
@@ -1,6 +1,6 @@
package main;
-use Test::More tests => 15;
+use Test::More tests => 18;
use lib 't/lib';
use Catalyst::Test 'TestApp';
use File::stat;
@@ -38,3 +38,8 @@
is( $response->content, '1text/csv3', 'Normal request content', );
}
+{
+ ok( my $response = request('/subtest_with_params'), 'Sub request with full params' );
+ is( $response->code, 200, 'OK status code' );
+ is( $response->content, 'foo33', 'Normal request content', );
+}
Modified: trunk/Catalyst-Plugin-SubRequest/t/lib/TestApp/Controller/Root.pm
===================================================================
--- trunk/Catalyst-Plugin-SubRequest/t/lib/TestApp/Controller/Root.pm 2012-07-18 19:29:23 UTC (rev 14330)
+++ trunk/Catalyst-Plugin-SubRequest/t/lib/TestApp/Controller/Root.pm 2012-07-19 03:39:54 UTC (rev 14331)
@@ -42,6 +42,18 @@
$c->res->body( $c->res->body() . $subreq_res->content_type );
}
+sub subtest_with_params :Global {
+ my($self, $c) = @_;
+ $c->res->body(
+ $c->subrequest('/plain_param', {},
+ { content => 'foo' }));
+}
+
+sub plain_param :Global {
+ my($self, $c) = @_;
+ $c->res->body($c->req->params->{content});
+}
+
sub typesetter : Global {
my ( $self, $c, $arg ) = @_;
$c->res->content_type( 'text/csv' );
More information about the Catalyst-commits
mailing list