Decode URIs with APR::Request if available
Andy Grundman [Thu, 29 Mar 2007 19:35:16 +0000 (19:35 +0000)]
Changes
lib/Catalyst/Engine.pm

diff --git a/Changes b/Changes
index 7856ab0..a5a16ca 100644 (file)
--- a/Changes
+++ b/Changes
@@ -5,6 +5,7 @@ This file documents the revision history for Perl extension Catalyst.
           * $c->uri_for (approx. 8x faster)
           * $c->engine->prepare_path (approx. 27x faster)
           * $c->engine->prepare_query_parameters (approx. 5x faster)
+        - If libapreq2 is installed, URIs are decoded using a faster C function.
         - Updated HTTP::Body dependency to 0.9 which fixes the following issues:
           * Handle when IE sometimes sends an extra CRLF after the POST body.
           * Empty fields in multipart/form-data POSTs are no longer ignored.
index 564cb42..fea294e 100644 (file)
@@ -20,6 +20,11 @@ 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
@@ -636,14 +641,18 @@ sub write {
 
 =head2 $self->unescape_uri($uri)
 
-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.
+Unescapes a given URI using the most efficient method available.  Engines
+can subclass to provide faster implementations.
 
 =cut
 
 sub unescape_uri {
     my $self = shift;
     
+    if ( HAS_APR ) {
+        return APR::Request::decode(@_);
+    }
+    
     my $e = URI::Escape::uri_unescape(@_);
     $e =~ s/\+/ /g;