- Fix Perl Critic test for hard tabs (t0m)
- Fix POD coverage (t0m)
- Added allow_ssl() (norbi)
+ - Added detach_on_redirect config option (norbi)
0.06 2007-03-06 11:00:00
- Added no_cache config option to support wildcard SSL certificates.
else {
$c->_ssl_strip_output(1);
$c->res->redirect( $redir );
+ $c->detach if $c->config->{require_ssl}->{detach_on_redirect};
}
}
}
http => 'www.mydomain.com',
remain_in_ssl => 0,
no_cache => 0,
+ detach_on_redirect => 1,
};
# in any controller methods that should be secured
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
--- /dev/null
+#!perl
+
+use strict;
+use warnings;
+
+use FindBin;
+use lib "$FindBin::Bin/lib";
+
+use Test::More tests => 4;
+use Catalyst::Test 'TestApp';
+
+{
+ TestApp->config->{require_ssl}->{detach_on_redirect} = 0;
+
+ # test an SSL redirect
+ ok( my $res = request('http://localhost/ssl/test_detach'), 'request ok' );
+ is( $res->header('location'), 'http://www.mydomain.com/redirect_from_the_action',
+ 'the action did the redirect after $c->require_ssl'
+ );
+}
+
+{
+ TestApp->config->{require_ssl}->{detach_on_redirect} = 1;
+
+ # test an SSL redirect
+ ok( my $res = request('http://localhost/ssl/test_detach'), 'request ok' );
+ is( $res->header('location'), 'https://localhost/ssl/test_detach',
+ 'the action finished in $c->require_ssl'
+ );
+}
$c->res->output( 'Maybe secured' );
}
+sub test_detach : Local {
+ my ( $self, $c ) = @_;
+
+ $c->require_ssl;
+
+ $c->res->redirect('http://www.mydomain.com/redirect_from_the_action');
+
+ $c->res->output( 'Test detach' );
+}
+
+
1;