Subject: | Improve STRICT_CONTENT_TYPE handling |
process() assumes that if the User-Agent is not Internet Explorer
(MSIE), the client can support the 'application/xhtml+xml' content-type
and updates the response accordingly. But what if it can't?
An alternative is to examine the 'Accept' header in the client's
request, to check for XHTML support in the User-Agent:
if ($self->config->{STRICT_CONTENT_TYPE}) {
my $accept = $c->req->header('Accept') || '';
$c->res->content_type(
$accept =~ m#application/xhtml\+xml#
? 'application/xhtml+xml; charset=utf-8'
: 'text/html; charset=utf-8'
);
}
Clients without XHTML support would receive the 'text/html' content-type
fallback. In the event IE ever supports 'application/xhtml+xml', these
clients would receive the proper content-type, too.