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

Re: XHTML 1.0 Content-Negotiation

From: Dominique HazaŽl-Massieux <dom@w3.org>
Date: Fri, 19 Aug 2005 12:46:00 +0200
To: James Pickering <jp29@cox.net>
Cc: www-qa@w3.org
Message-Id: <1124448360.5590.241.camel@stratustier>

Le samedi 06 aoŻt 2005 ŗ 21:49 +0100, Jim Ley a ťcrit :
> "James Pickering" <jp29@cox.net>
> >Their Technical Department was not encouraging about
> >effecting Content-Negotiation but I found that inserting the following
> >PHP code ..........
> > [...]
> 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.

FWIW, I have been using the PHP class available at:
http://jking.dark-phantasy.com/code/php/class.contentnegotiation.phps to
deal with my content negotiation needs. I'm not sure how complete it is
in terms of parsing correctly HTTP headers (anybody knows a test suite I
could use?), but at least it passes the following tests:

$tests = array("text/html,application/xhtml+xml" => "text/html",
               "text/html;q=0.1, application/xhtml+xml;q=0.5" =>
               "text/html;q=0.1, application/xhtml+xml;q=0" =>
               "text/html;q=\"0.5\",application/xhtml+xml;q=\"0.5\"" =>

foreach($tests as $input=>$output) {
  $conneg = new contentNegotiation();
   if ($conneg->compareQ("text/html,application/xhtml+xml")==$output) {
    echo "Success\n" ;
  } else {
    echo "failure\n" ;

(I've found many sites that proposed to deal with the particular case of
conneg between application/xhtml+xml and text/html, e.g.:
but none of their code seems to pass correctly the tests above)

Depending on the feedback I get, I'll update

Dominique HazaŽl-Massieux - http://www.w3.org/People/Dom/
Received on Friday, 19 August 2005 10:46:08 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 20:40:36 UTC