[Catalyst] hostname

Wade.Stuart at fallon.com Wade.Stuart at fallon.com
Wed Jan 9 19:28:05 GMT 2008


Ash Berlin <ash_cpan at firemirror.com> wrote on 01/09/2008 05:39:22 AM:

>
> On Jan 9, 2008, at 11:12 AM, Octavian Rasnita wrote:
>
> > From: "Ashley" <apv at sedition.com>
> >
> >> Oh, I was too fast. Blush. You mean without the context object. :(
> >
> > Yes, that's what I want.
> > Can't the context object be accessed in MyApp.pm?
> >
> > Thanks.
> >
> > Octavian
> >
> >
>
> Currently MyApp.pm *is* the context object. The problem is Catalyst
> has no idea of the hostname until it sees the request headers - you
> can have multiple hosts point at the same Catalyst app. Only you know
> what the hostname is - so you'll have to set it in the config.
>
> -ash

Not really,  the http request also includes the clients version of the host
it is requesting from.  This is how virtual servers work (where one http
process serves different data based on the hostname the client is
requesting).  $c->req->header( 'Host' ) provides the information needed
from the context object, but is unavailable to MyApp.pm.  cookie_domain
setting in Catalyst::Plugin::Session::State::Cookie needs to be set to
reflect the requested hostname in this case else the browser will not set
the cookie nor include it on round trips to the application if the
requested host/domain is different from the host that Catalyst believes it
is running as.  I believe a workaround for this issue is to leave the
cookie_domain setting unset which I believe will produce a cookie that is
not stating its domain and the client browser will treat as locked to the
requested host's name for the domain.



So if you want the cookie to be set on the client without worrying about
the hostname requested don't set the domain_name or set the domain_name to
the common domain for all hosts.



-Wade







More information about the Catalyst mailing list