Subject: | Head middleware conflicts with ETag middleware |
Date: | Wed, 15 Nov 2017 13:57:42 +0000 |
To: | bug-Catalyst-Runtime [...] rt.cpan.org |
From: | Robert Rothenberg <rrwo [...] cpan.org> |
By including the Head middleware in the defaults, this conflicts with the
ETag middleware. The result is that HEAD requests return different ETags
than GET requests.
I've been able to work around the issue in a Catalyst app with this:
around default_middleware => sub {
my $next = shift;
my $self = shift;
my @mw = grep
{ !$_->isa('Plack::Middleware::Head') } $self->$next(@_);
return @mw;
};
and then manually adding the middleware in the PSGI file:
enable "Plack::Middleware::Head";
enable "Plack::Middleware::ConditionalGET";
enable "Plack::Middleware::ETag";
That feels like an awful hack.
I'm not sure what a better solution is.
The easiest fix is to make it easier to modify the default middleware in the
configuration.
I think a better long-term solution for Catalyst is to only load middleware
that is needed, such as the stash middleware.
The recommended defaults can be loaded by a plugin, or maybe multiple plugins.