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

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
application/xhtml+xml.

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.

Cordially,
Alexandre Alapetite
http://alexandre.alapetite.net

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