Implemented detach_on_redirect config option.
[catagits/Catalyst-Plugin-RequireSSL.git] / lib / Catalyst / Plugin / RequireSSL.pm
index 6aafbc4..edf613f 100644 (file)
@@ -21,6 +21,7 @@ sub require_ssl {
         else {
             $c->_ssl_strip_output(1);
             $c->res->redirect( $redir );
+            $c->detach if $c->config->{require_ssl}->{detach_on_redirect};
         }
     }
 }
@@ -134,6 +135,7 @@ Catalyst::Plugin::RequireSSL - Force SSL mode on select pages
         http => 'www.mydomain.com',
         remain_in_ssl => 0,
         no_cache => 0,
+        detach_on_redirect => 1,
     };
 
     # in any controller methods that should be secured
@@ -182,6 +184,13 @@ users will be redirected back to non-SSL mode as soon as possible.
 If you have a wildcard certificate you will need to set this option if you are
 using multiple domains on one instance of Catalyst.
 
+    detach_on_redirect 
+
+By default C<< $c->require_ssl >> only calls C<< $c->response->redirect >> but
+does not stop request processing (so it returns and subsequent statements are
+run). This is probably not what you want. If you set this option to a true
+value C<< $c->require_ssl >> will call C<< $c->detach >> when it redirects.
+
 =head1 METHODS
 
 =head2 require_ssl