Added req->query_keywords method
[catagits/Catalyst-Runtime.git] / lib / Catalyst / Engine.pm
index fea294e..5902c9c 100644 (file)
@@ -7,7 +7,6 @@ use Data::Dump qw/dump/;
 use HTML::Entities;
 use HTTP::Body;
 use HTTP::Headers;
-use URI::Escape ();
 use URI::QueryParam;
 use Scalar::Util ();
 
@@ -20,11 +19,6 @@ use overload '""' => sub { return ref shift }, fallback => 1;
 # Amount of data to read from input on each pass
 our $CHUNKSIZE = 64 * 1024;
 
-# See if we can use libapreq2 for URI unescaping
-use constant HAS_APR => eval {
-    require APR::Request;
-};
-
 =head1 NAME
 
 Catalyst::Engine - The Catalyst Engine
@@ -454,8 +448,9 @@ sub prepare_query_parameters {
     my ( $self, $c, $query_string ) = @_;
     
     # Check for keywords (no = signs)
+    # (yes, index() is faster than a regex :))
     if ( index( $query_string, '=' ) < 0 ) {
-        $c->request->keywords( $self->unescape_uri($query_string) );
+        $c->request->query_keywords( $self->unescape_uri($query_string) );
         return;
     }
 
@@ -641,22 +636,18 @@ sub write {
 
 =head2 $self->unescape_uri($uri)
 
-Unescapes a given URI using the most efficient method available.  Engines
-can subclass to provide faster implementations.
+Unescapes a given URI using the most efficient method available.  Engines such
+as Apache may implement this using Apache's C-based modules, for example.
 
 =cut
 
 sub unescape_uri {
-    my $self = shift;
-    
-    if ( HAS_APR ) {
-        return APR::Request::decode(@_);
-    }
+    my ( $self, $str ) = @_;
     
-    my $e = URI::Escape::uri_unescape(@_);
-    $e =~ s/\+/ /g;
+    $str =~ s/%([0-9A-Fa-f]{2})/chr(hex($1))/eg;
+    $str =~ s/\+/ /g;
     
-    return $e;
+    return $str;
 }
 
 =head2 $self->finalize_output