Retrieve REQUEST_URI before calling ->canonical since that decodes URI
Tatsuhiko Miyagawa [Mon, 11 Jan 2010 22:59:17 +0000 (22:59 +0000)]
safe characters, so we can properly test those REQUEST_URI
undecoded-ness. Required for Catalyst and Plack to retrieve as raw
value as possible.

lib/HTTP/Request/AsCGI.pm

index 099ce1d..274dda9 100644 (file)
@@ -54,6 +54,9 @@ sub new {
     $uri->port(80)          unless $uri->port;
     $uri->host_port($host)  unless !$host || ( $host eq $uri->host_port );
 
+    # Get it before canonicalized so REQUEST_URI can be as raw as possible
+    my $request_uri = $uri->path_query;
+
     $uri = $uri->canonical;
 
     my $environment = {
@@ -70,7 +73,7 @@ sub new {
         REMOTE_ADDR       => '127.0.0.1',
         REMOTE_HOST       => 'localhost',
         REMOTE_PORT       => int( rand(64000) + 1000 ),                   # not in RFC 3875
-        REQUEST_URI       => $uri->path_query,                            # not in RFC 3875
+        REQUEST_URI       => $request_uri,                                # not in RFC 3875
         REQUEST_METHOD    => $request->method,
         @_
     };