[Catalyst-commits] r6895 - in trunk/Catalyst-Runtime: . lib/Catalyst lib/Catalyst/Engine t

andyg at dev.catalyst.perl.org andyg at dev.catalyst.perl.org
Fri Sep 14 18:10:32 GMT 2007


Author: andyg
Date: 2007-09-14 18:10:31 +0100 (Fri, 14 Sep 2007)
New Revision: 6895

Modified:
   trunk/Catalyst-Runtime/Changes
   trunk/Catalyst-Runtime/lib/Catalyst/Engine/CGI.pm
   trunk/Catalyst-Runtime/lib/Catalyst/Request.pm
   trunk/Catalyst-Runtime/t/live_component_controller_action_chained.t
   trunk/Catalyst-Runtime/t/live_engine_request_headers.t
   trunk/Catalyst-Runtime/t/live_engine_request_parameters.t
   trunk/Catalyst-Runtime/t/live_engine_request_uri.t
Log:
Fixed bug where req->base and req->uri would include ':443' when in SSL mode

Modified: trunk/Catalyst-Runtime/Changes
===================================================================
--- trunk/Catalyst-Runtime/Changes	2007-09-14 16:52:43 UTC (rev 6894)
+++ trunk/Catalyst-Runtime/Changes	2007-09-14 17:10:31 UTC (rev 6895)
@@ -11,6 +11,8 @@
           'Resource temporarily unavailable'.
         - 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.
 
 5.7010  2007-08-22 07:41:00
         - Resource forks in 5.7009

Modified: trunk/Catalyst-Runtime/lib/Catalyst/Engine/CGI.pm
===================================================================
--- trunk/Catalyst-Runtime/lib/Catalyst/Engine/CGI.pm	2007-09-14 16:52:43 UTC (rev 6894)
+++ trunk/Catalyst-Runtime/lib/Catalyst/Engine/CGI.pm	2007-09-14 17:10:31 UTC (rev 6895)
@@ -143,10 +143,10 @@
     # Using URI directly is way too slow, so we construct the URLs manually
     my $uri_class = "URI::$scheme";
     
-    # HTTP_HOST will include the port even if it's 80
-    $host =~ s/:80$//;
+    # HTTP_HOST will include the port even if it's 80/443
+    $host =~ s/:(?:80|443)$//;
     
-    if ( $port != 80 && $host !~ /:/ ) {
+    if ( $port !~ /^(?:80|443)$/ && $host !~ /:/ ) {
         $host .= ":$port";
     }
     

Modified: trunk/Catalyst-Runtime/lib/Catalyst/Request.pm
===================================================================
--- trunk/Catalyst-Runtime/lib/Catalyst/Request.pm	2007-09-14 16:52:43 UTC (rev 6894)
+++ trunk/Catalyst-Runtime/lib/Catalyst/Request.pm	2007-09-14 17:10:31 UTC (rev 6895)
@@ -6,6 +6,8 @@
 use IO::Socket qw[AF_INET inet_aton];
 use Carp;
 use utf8;
+use URI::http;
+use URI::https;
 use URI::QueryParam;
 
 __PACKAGE__->mk_accessors(

Modified: trunk/Catalyst-Runtime/t/live_component_controller_action_chained.t
===================================================================
--- trunk/Catalyst-Runtime/t/live_component_controller_action_chained.t	2007-09-14 16:52:43 UTC (rev 6894)
+++ trunk/Catalyst-Runtime/t/live_component_controller_action_chained.t	2007-09-14 17:10:31 UTC (rev 6895)
@@ -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' );
     }
 

Modified: trunk/Catalyst-Runtime/t/live_engine_request_headers.t
===================================================================
--- trunk/Catalyst-Runtime/t/live_engine_request_headers.t	2007-09-14 16:52:43 UTC (rev 6894)
+++ trunk/Catalyst-Runtime/t/live_engine_request_headers.t	2007-09-14 17:10:31 UTC (rev 6895)
@@ -12,7 +12,6 @@
 use Catalyst::Request;
 use HTTP::Headers;
 use HTTP::Request::Common;
-use URI;
 
 {
     my $creq;

Modified: trunk/Catalyst-Runtime/t/live_engine_request_parameters.t
===================================================================
--- trunk/Catalyst-Runtime/t/live_engine_request_parameters.t	2007-09-14 16:52:43 UTC (rev 6894)
+++ trunk/Catalyst-Runtime/t/live_engine_request_parameters.t	2007-09-14 17:10:31 UTC (rev 6895)
@@ -12,7 +12,6 @@
 use Catalyst::Request;
 use HTTP::Headers;
 use HTTP::Request::Common;
-use URI;
 
 {
     my $creq;

Modified: trunk/Catalyst-Runtime/t/live_engine_request_uri.t
===================================================================
--- trunk/Catalyst-Runtime/t/live_engine_request_uri.t	2007-09-14 16:52:43 UTC (rev 6894)
+++ trunk/Catalyst-Runtime/t/live_engine_request_uri.t	2007-09-14 17:10:31 UTC (rev 6895)
@@ -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




More information about the Catalyst-commits mailing list