Re: XHTML 1.0 Content-Negotiation

"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 UTC