[Catalyst] [ANNOUNCE] Catalyst-Runtime-5.89002-TRIAL PSGI Catalyst - third development release

Pedro Melo melo at simplicidade.org
Wed Mar 2 15:41:30 GMT 2011


Hi,

On Wed, Mar 2, 2011 at 3:27 PM, Florian Ragwitz <rafl at debian.org> wrote:
> Pedro Melo <melo at simplicidade.org> writes:
>
>> I've noticed a small difference with Catalyst::Test. The latest stable
>> version include two headers, 'host' and 'https'. They are missing from
>> this version.
>>
>> Is this a documented change that I missed or a bug?
>
> It's certainly not the former, but I'm not sure it's the latter either.
>
> When doing local requests using Catalyst::Test (i.e. without
> CATALYST_SERVER to do remote testing set), HTTP::Request::AsCGI used to
> be used. We got rid of that and switched to using the infrastructure
> provided by Plack::Test instead.
>
> For local requests, Plack::Test::MockHTTP will now be used, so the
> HTTP::Requests from your tests will be turned into PSGI env hashes and
> then handled by your app. Apparently Plack::Test::MockHTTP doesn't set
> either HOST or HTTPS headers like HTTP::Request::AsCGI does. Instead it
> provides the server host in the SERVER_NAME header, and the uri scheme
> (http or https) in psgi.url_scheme.
>
> I'm not sure if this change of behaviour is something we should fix
> though. The engine knows that a request is secure by checking
> psgi.url_scheme, and applications can ask for that using
> $ctx->request->secure. Similarly, the request host was, is, and probably
> always will be available as $ctx->request->host.

Right now I don't need https/secure, but I do need the host.

At first I assumed that something like $ctx->request->host would be
available but its not:

[error] Caught exception in E5::Sites::Gestao::View::HTML->process
"Can't locate object method "host" via package "Catalyst::Request"

Thats with psgi branch, but I'm pretty sure stable doesn't have it either.

> Did these changes actually cause your app to break? If so, what exactly
> does the code that broke look like?

Yes, it did because the app switched template paths based on the
hostname used to access the app.

The code I was using was:

my $host = $c->request->headers->header('Host');
$host =~ s/:\d+$//;

I would prefer %ctx->request->host though, much cleaner.

Bye,
-- 
Pedro Melo
http://www.simplicidade.org/
xmpp:melo at simplicidade.org
mailto:melo at simplicidade.org



More information about the Catalyst mailing list