W3C home > Mailing lists > Public > www-qa@w3.org > August 2005

Re: XHTML 1.0 Content-Negotiation

From: Jim Ley <jim@jibbering.com>
Date: Sat, 6 Aug 2005 21:49:30 +0100
Message-ID: <001a01c59ac8$588539f0$0300000a@Snufkin>
To: "James Pickering" <jp29@cox.net>, <www-qa@w3.org>

"James Pickering" <jp29@cox.net>
>Their Technical Department was not encouraging about
>effecting Content-Negotiation but I found that inserting the following
>PHP code ..........

>if ( isset($_SERVER["HTTP_ACCEPT"]) and
>stristr($_SERVER["HTTP_ACCEPT"],"application/xhtml+xml") ) {My
>header("Content-type: application/xhtml+xml");
>}
>else {
>header("Content-type: text/html");
>}

Unfortunately this is incorrect, and would violate HTTP 1.1, the Accept 
header is considerably richer in what it can say than the above uses.

Particularly q values of 0, so you should also take care to not send xhtml 
to an UA with accept headers containing:

text/html,x.application/xhtml+xml
text/html,application/xhtml+xml+chickens
text/html,application/xhtml+xml;q=0
text/html,application/xhtml+xml; q=0
text/html,application/prs.jibberjim; level="application/xhtml+xml"

or probably some other things, this is by no means an exhaustive list.  See 
http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.1 for more 
information.

Cheers,

Jim. 
Received on Saturday, 6 August 2005 20:50:03 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Sunday, 6 December 2009 12:14:01 GMT