[Catalyst-commits] r6896 - in trunk/Catalyst-Engine-Apache: .
lib/Catalyst/Engine lib/Catalyst/Engine/Apache2 t
andyg at dev.catalyst.perl.org
andyg at dev.catalyst.perl.org
Fri Sep 14 18:25:35 GMT 2007
Author: andyg
Date: 2007-09-14 18:25:34 +0100 (Fri, 14 Sep 2007)
New Revision: 6896
Modified:
trunk/Catalyst-Engine-Apache/Changes
trunk/Catalyst-Engine-Apache/lib/Catalyst/Engine/Apache.pm
trunk/Catalyst-Engine-Apache/lib/Catalyst/Engine/Apache2/MP19.pm
trunk/Catalyst-Engine-Apache/lib/Catalyst/Engine/Apache2/MP20.pm
trunk/Catalyst-Engine-Apache/t/live_component_controller_action_chained.t
trunk/Catalyst-Engine-Apache/t/live_engine_request_headers.t
trunk/Catalyst-Engine-Apache/t/live_engine_request_parameters.t
trunk/Catalyst-Engine-Apache/t/live_engine_request_uri.t
trunk/Catalyst-Engine-Apache/t/live_plugin_loaded.t
Log:
The Apache engine also needed a fix for %2b encoding.
Merged HTTPS base fix from Runtime.
Synced tests with Runtime.
Modified: trunk/Catalyst-Engine-Apache/Changes
===================================================================
--- trunk/Catalyst-Engine-Apache/Changes 2007-09-14 17:10:31 UTC (rev 6895)
+++ trunk/Catalyst-Engine-Apache/Changes 2007-09-14 17:25:34 UTC (rev 6896)
@@ -1,5 +1,11 @@
This file documents the revision history for Catalyst::Engine::Apache.
+1.12
+ - Fixed bug where %2b in query parameter is doubly decoded to ' ', instead of '+'
+ (Gavin Henry, Tatsuhiko Miyagawa)
+ - Fixed bug where req->base and req->uri would include a port number when running
+ in SSL mode.
+
1.11 2007-05-18 08:30:00
- Don't 'use mod_perl;' as this may not work on some mod_perl installations.
Modified: trunk/Catalyst-Engine-Apache/lib/Catalyst/Engine/Apache.pm
===================================================================
--- trunk/Catalyst-Engine-Apache/lib/Catalyst/Engine/Apache.pm 2007-09-14 17:10:31 UTC (rev 6895)
+++ trunk/Catalyst-Engine-Apache/lib/Catalyst/Engine/Apache.pm 2007-09-14 17:25:34 UTC (rev 6896)
@@ -14,7 +14,7 @@
$ENV{MOD_PERL_API_VERSION} >= 2
);
-our $VERSION = '1.11';
+our $VERSION = '1.12';
__PACKAGE__->mk_accessors(qw/apache return/);
@@ -114,7 +114,7 @@
# Using URI directly is way too slow, so we construct the URLs manually
my $uri_class = "URI::$scheme";
- if ( $port != 80 && $host !~ /:/ ) {
+ if ( $port !~ /^(?:80|443)$/ && $host !~ /:/ ) {
$host .= ":$port";
}
Modified: trunk/Catalyst-Engine-Apache/lib/Catalyst/Engine/Apache2/MP19.pm
===================================================================
--- trunk/Catalyst-Engine-Apache/lib/Catalyst/Engine/Apache2/MP19.pm 2007-09-14 17:10:31 UTC (rev 6895)
+++ trunk/Catalyst-Engine-Apache/lib/Catalyst/Engine/Apache2/MP19.pm 2007-09-14 17:25:34 UTC (rev 6896)
@@ -17,12 +17,10 @@
sub ok_constant { Apache::OK }
sub unescape_uri {
- my $self = shift;
-
- my $e = Apache::URI::unescape_url(@_);
- $e =~ s/\+/ /g;
+ my ( $self, $str ) = @_;
- return $e;
+ $str =~ s/\+/ /g;
+ return Apache::URI::unescape_url($str);
}
1;
Modified: trunk/Catalyst-Engine-Apache/lib/Catalyst/Engine/Apache2/MP20.pm
===================================================================
--- trunk/Catalyst-Engine-Apache/lib/Catalyst/Engine/Apache2/MP20.pm 2007-09-14 17:10:31 UTC (rev 6895)
+++ trunk/Catalyst-Engine-Apache/lib/Catalyst/Engine/Apache2/MP20.pm 2007-09-14 17:25:34 UTC (rev 6896)
@@ -19,12 +19,10 @@
sub ok_constant { Apache2::Const::OK }
sub unescape_uri {
- my $self = shift;
-
- my $e = Apache2::URI::unescape_url(@_);
- $e =~ s/\+/ /g;
+ my ( $self, $str ) = @_;
- return $e;
+ $str =~ s/\+/ /g;
+ return Apache2::URI::unescape_url($str);
}
1;
Modified: trunk/Catalyst-Engine-Apache/t/live_component_controller_action_chained.t
===================================================================
--- trunk/Catalyst-Engine-Apache/t/live_component_controller_action_chained.t 2007-09-14 17:10:31 UTC (rev 6895)
+++ trunk/Catalyst-Engine-Apache/t/live_component_controller_action_chained.t 2007-09-14 17:25:34 UTC (rev 6896)
@@ -10,7 +10,7 @@
BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 1; }
-use Test::More tests => 109*$iters;
+use Test::More tests => 118*$iters;
use Catalyst::Test 'TestApp';
if ( $ENV{CAT_BENCHMARK} ) {
@@ -699,7 +699,7 @@
'http://localhost/action/chained/to_root' ),
'uri_for with chained root action as arg' );
like( $response->content,
- qr(URI:http://[^/]+/),
+ qr(URI:https?://[^/]+/),
'Correct URI generated' );
}
@@ -766,4 +766,66 @@
is( $response->content, '; ', 'Content OK' );
}
+ #
+ # Higher Args() hiding more specific CaptureArgs chains sections
+ #
+ {
+ my @expected = qw[
+ TestApp::Controller::Action::Chained->begin
+ TestApp::Controller::Action::Chained->cc_base
+ TestApp::Controller::Action::Chained->cc_link
+ TestApp::Controller::Action::Chained->cc_anchor
+ TestApp::Controller::Action::Chained->end
+ ];
+
+ my $expected = join ', ', @expected;
+
+ ok( my $response = request('http://localhost/chained/choose_capture/anchor.html'),
+ 'Choose between an early Args() and a later more ideal chain' );
+ is( $response->header('X-Catalyst-Executed') => $expected, 'Executed actions');
+ is( $response->content => '; ', 'Content OK' );
+ }
+
+ #
+ # Less specific chain not being seen correctly due to earlier looser capture
+ #
+ {
+ my @expected = qw[
+ TestApp::Controller::Action::Chained->begin
+ TestApp::Controller::Action::Chained->cc_base
+ TestApp::Controller::Action::Chained->cc_b
+ TestApp::Controller::Action::Chained->cc_b_link
+ TestApp::Controller::Action::Chained->cc_b_anchor
+ TestApp::Controller::Action::Chained->end
+ ];
+
+ my $expected = join ', ', @expected;
+
+ ok( my $response = request('http://localhost/chained/choose_capture/b/a/anchor.html'),
+ 'Choose between a more specific chain and an earlier looser one' );
+ is( $response->header('X-Catalyst-Executed') => $expected, 'Executed actions');
+ is( $response->content => 'a; ', 'Content OK' );
+ }
+
+ #
+ # Check we get the looser one when it's the correct match
+ #
+ {
+ my @expected = qw[
+ TestApp::Controller::Action::Chained->begin
+ TestApp::Controller::Action::Chained->cc_base
+ TestApp::Controller::Action::Chained->cc_a
+ TestApp::Controller::Action::Chained->cc_a_link
+ TestApp::Controller::Action::Chained->cc_a_anchor
+ TestApp::Controller::Action::Chained->end
+ ];
+
+ my $expected = join ', ', @expected;
+
+ ok( my $response = request('http://localhost/chained/choose_capture/a/a/anchor.html'),
+ 'Choose between a more specific chain and an earlier looser one' );
+ is( $response->header('X-Catalyst-Executed') => $expected, 'Executed actions');
+ is( $response->content => 'a; anchor.html', 'Content OK' );
+ }
+
}
Modified: trunk/Catalyst-Engine-Apache/t/live_engine_request_headers.t
===================================================================
--- trunk/Catalyst-Engine-Apache/t/live_engine_request_headers.t 2007-09-14 17:10:31 UTC (rev 6895)
+++ trunk/Catalyst-Engine-Apache/t/live_engine_request_headers.t 2007-09-14 17:25:34 UTC (rev 6896)
@@ -12,7 +12,6 @@
use Catalyst::Request;
use HTTP::Headers;
use HTTP::Request::Common;
-use URI;
{
my $creq;
Modified: trunk/Catalyst-Engine-Apache/t/live_engine_request_parameters.t
===================================================================
--- trunk/Catalyst-Engine-Apache/t/live_engine_request_parameters.t 2007-09-14 17:10:31 UTC (rev 6895)
+++ trunk/Catalyst-Engine-Apache/t/live_engine_request_parameters.t 2007-09-14 17:25:34 UTC (rev 6896)
@@ -6,13 +6,12 @@
use FindBin;
use lib "$FindBin::Bin/lib";
-use Test::More tests => 30;
+use Test::More tests => 35;
use Catalyst::Test 'TestApp';
use Catalyst::Request;
use HTTP::Headers;
use HTTP::Request::Common;
-use URI;
{
my $creq;
@@ -39,7 +38,17 @@
{
my $creq;
+ ok( my $response = request("http://localhost/dump/request?q=foo%2bbar"),
+ 'Request' );
+ ok( $response->is_success, 'Response Successful 2xx' );
+ is( $response->content_type, 'text/plain', 'Response Content-Type' );
+ ok( eval '$creq = ' . $response->content );
+ is $creq->{parameters}->{q}, 'foo+bar', '%2b not double decoded';
+}
+{
+ my $creq;
+
my $parameters = {
'a' => [qw(A b C d E f G)],
'%' => [ '%', '"', '& - &' ],
Modified: trunk/Catalyst-Engine-Apache/t/live_engine_request_uri.t
===================================================================
--- trunk/Catalyst-Engine-Apache/t/live_engine_request_uri.t 2007-09-14 17:10:31 UTC (rev 6895)
+++ trunk/Catalyst-Engine-Apache/t/live_engine_request_uri.t 2007-09-14 17:25:34 UTC (rev 6896)
@@ -6,7 +6,7 @@
use FindBin;
use lib "$FindBin::Bin/lib";
-use Test::More tests => 44;
+use Test::More tests => 49;
use Catalyst::Test 'TestApp';
use Catalyst::Request;
@@ -37,6 +37,21 @@
is( $creq->base . $creq->path, $creq->uri, 'Base + Path ok' );
}
+# test base is correct for HTTPS URLs
+SKIP:
+{
+ if ( $ENV{CATALYST_SERVER} ) {
+ skip 'Using remote server', 5;
+ }
+
+ local $ENV{HTTPS} = 'on';
+ ok( my $response = request('https://localhost/engine/request/uri'), 'HTTPS Request' );
+ ok( $response->is_success, 'Response Successful 2xx' );
+ ok( eval '$creq = ' . $response->content, 'Unserialize Catalyst::Request' );
+ is( $creq->base, 'https://localhost/', 'HTTPS base ok' );
+ is( $creq->uri, 'https://localhost/engine/request/uri', 'HTTPS uri ok' );
+}
+
# test that we can use semi-colons as separators
{
my $parameters = {
@@ -88,7 +103,7 @@
{
ok( my $response = request('http://localhost/engine/request/uri/uri_with_object'), 'Request' );
ok( $response->is_success, 'Response Successful 2xx' );
- like( $response->header( 'X-Catalyst-Param-a' ), qr(http://localhost[^/]*/), 'param "a" ok' );
+ like( $response->header( 'X-Catalyst-Param-a' ), qr(https?://localhost[^/]*/), 'param "a" ok' );
}
# test that uri_with is utf8 safe
Modified: trunk/Catalyst-Engine-Apache/t/live_plugin_loaded.t
===================================================================
--- trunk/Catalyst-Engine-Apache/t/live_plugin_loaded.t 2007-09-14 17:10:31 UTC (rev 6895)
+++ trunk/Catalyst-Engine-Apache/t/live_plugin_loaded.t 2007-09-14 17:25:34 UTC (rev 6896)
@@ -12,6 +12,7 @@
my @expected = qw[
Catalyst::Plugin::Test::Errors
Catalyst::Plugin::Test::Headers
+ Catalyst::Plugin::Test::Inline
Catalyst::Plugin::Test::Plugin
TestApp::Plugin::FullyQualified
];
More information about the Catalyst-commits
mailing list