W3C home > Mailing lists > Public > www-validator@w3.org > April 2008

Re: please add Accept header to http request containing application/xhtml+xml

From: Alexandre Alapetite <alexandre@alapetite.net>
Date: Mon, 21 Apr 2008 18:17:21 +0200
Message-ID: <42a8e2e00804210917j5c99c8a9k5b3d0807308d227c@mail.gmail.com>
To: "Etienne Miret" <elimerl@gmail.com>, "Dean Edridge" <dean@55.co.nz>
Cc: www-validator@w3.org

Hi again,

Etienne Miret wrote:
> However, in the real-world some UA won't send a correct accept header,
> and those UA are typically unable to handle XHTML, so you *need* hacks.
> There is no way around it. You need some dirty hack if you want to support IE.

Internet Explorer (4, 5, 6, 7, 8) does send an Accept header, and it
is not empty.

Dean Edridge wrote:
> IMHO it is not good practise for any web server to send XHTML
> to a user-agent without first knowing that the user-agent accepts XHTML.
> This may seem like an odd concept to some but it is just the way things are
> if you want to use XHTML on the web today.

I am not aware of any user agent that does NOT send an Accept header
at all, and to which it would be problematic to send

The following algorithm does not require any user agent sniffing, is
not that dirty, and works with all user agents I have been able to put
my hands on (including W3C validator):

1) If there is no Accept header at all, then send
application/xhtml+xml; (compatible with IE and W3C validator)

2) Else if Accept header contains application/xhtml+xml with a q
different than 0, then send application/xhtml+xml; (compatible with
modern browsers)

3) Otherwise (i.e. if Accept header is not empty and does not contain
application/xhtml+xml with a q different than 0), so send text/html;
(for IE compatibility)

But the whole concept of doing pseudo content negotiation with 4 lines
of poor PHP, or with a rewrite rule hack in a .htaccess is just not
good enough. In PHP, it is possible to implement a full standard
content negotiation mechanism, but it is not possible using a simple
rewrite rule in a .htaccess.

Alexandre Alapetite
Received on Monday, 21 April 2008 16:17:57 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 1 March 2016 14:17:55 UTC