missed one url-rewrite.
[catagits/Catalyst-Plugin-Session-State-Cookie.git] / FastMmap.pm
index 5b5e460..ed6325d 100644 (file)
@@ -9,7 +9,7 @@ use URI;
 use URI::Find;
 use File::Temp 'tempdir';
 
-our $VERSION = '0.04';
+our $VERSION = '0.06';
 
 __PACKAGE__->mk_classdata('_session');
 __PACKAGE__->mk_accessors('sessionid');
@@ -37,8 +37,10 @@ Fast sessions.
 
 sub finalize {
     my $c        = shift;
-    my $redirect = $c->response->redirect;
-    $c->response->redirect( $c->uri($redirect) ) if $redirect;
+    unless ($c->config->{no_url_rewrite}) {
+        my $redirect = $c->response->redirect;
+        $c->response->redirect( $c->uri($redirect) ) if $redirect;
+    }
     if ( my $sid = $c->sessionid ) {
         $c->_session->set( $sid, $c->session );
         my $set = 1;
@@ -46,16 +48,18 @@ sub finalize {
             $set = 0 if $cookie->value eq $sid;
         }
         $c->response->cookies->{session} = { value => $sid } if $set;
-        my $finder = URI::Find->new(
-            sub {
-                my ( $uri, $orig ) = @_;
-                my $base = $c->request->base;
-                return $orig unless $orig =~ /^$base/;
-                return $orig if $uri->path =~ /\/-\//;
-                return $c->uri($orig);
-            }
-        );
-        $finder->find( \$c->response->{output} );
+        unless ($c->config->{no_url_rewrite}) {
+          my $finder = URI::Find->new(
+              sub {
+                  my ( $uri, $orig ) = @_;
+                  my $base = $c->request->base;
+                  return $orig unless $orig =~ /^$base/;
+                  return $orig if $uri->path =~ /\/-\//;
+                  return $c->uri($orig);
+             }
+          );
+          $finder->find( \$c->res->{output} ) if $c->res->output;
+        }
     }
     return $c->NEXT::finalize(@_);
 }
@@ -83,7 +87,10 @@ sub session {
     my $c = shift;
     return $c->{session} if $c->{session};
     my $sid = $c->sessionid;
-    if ( $sid && ( $c->{session} = $c->_session->get($sid) ) ) {
+    if (   $sid
+        && $c->_session
+        && ( $c->{session} = $c->_session->get($sid) ) )
+    {
         $c->log->debug(qq/Found session "$sid"/) if $c->debug;
         return $c->{session};
     }
@@ -142,13 +149,40 @@ sub uri {
     return $uri;
 }
 
+=head2 CONFIG OPTIONS
+
+=head3 no_url_rewrite
+
+To disable automatic storing of sessions in the url, 
+you can disable the url rewriting for session by setting 
+this to a true value.
+
+=head3 cache_root
+
+The root directory for the session cache. defaults to a
+tempdir.
+
+=head3 default_expires_in
+
+how many seconds until the session expires. defaults to 1 day
+
+=head3 auto_purge_interval
+
+How often should the system purge sessions. Defaults to 1 time
+per day.
+
+=head3 auto_purge_on_set
+
+Is auto purge enabled? defaults to true.
+
 =head1 SEE ALSO
 
-L<Catalyst>.
+L<Catalyst> L<Cache::FastMmap>.
 
 =head1 AUTHOR
 
 Sebastian Riedel, C<sri@cpan.org>
+Marcus Ramberg C<mramberg@cpan.org>
 
 =head1 COPYRIGHT