[Catalyst] Usage of $c->uri_for and $c->res->redirect

Bill Moseley moseley at hank.org
Wed Mar 26 20:50:42 GMT 2008


On Wed, Mar 26, 2008 at 01:13:13PM -0700, Dustin Suchter wrote:
> Let's say I want to send people back and forth between an HTTP 
> connection and an HTTPS connection on a server based on some action. For 
> example, clicking on a "logout" button from within my application while 
> connected via HTTPS does something like:
> 
> $c->res->redirect("http://foo.com/");

Have you looked at the RequireSSL plugin?

I use a modified version where I add "SSL" to the attributes of the
actions that need to be SSL.  That avoids running my auto() methods
before the action runs, unlike the plugin on CPAN.

Under the test server I get this when I go to a secure page:

[warn] RequireSSL: Would have redirected to https://localhost:3000/some/secure/page

It's not that great of a setup because the way it works is by sending a
redirect, but not bad if you only have a few pages that require SSL.

BTW -- for resources (js, css) that may not be served via the
application server there's a trick of not specifying https:// or
http://, but just leave off the scheme.  I.e.:

    //resources.example.com/css/print.css

And that will use whatever the current page scheme is, IIRC.

-- 
Bill Moseley
moseley at hank.org




More information about the Catalyst mailing list