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 10:57:56 +0200
Message-ID: <42a8e2e00804210157g1917bfc6hd6fcfd8a6a025372@mail.gmail.com>
To: "Etienne Miret" <elimerl@gmail.com>
Cc: www-validator@w3.org, "Olivier Thereaux" <ot@w3.org>

Actually, just for the record, when a client does not send an Accept
header at all, it has the same meaning as "Accept: */*".

Furthermore, if a resource is coded for application/xhtml+xml, is
should be sent as such when the Accept header is empty.

Although far the full content negotiation specification, here is the
Apache rule I use when I cannot use a proper content negotiation with
a type-map (.var):

<IfModule mod_rewrite.c>
	RewriteEngine On
	RewriteCond %{HTTP_ACCEPT} ^$ [OR]
	RewriteCond %{HTTP_ACCEPT}
\bapplication/xhtml\+xml\b(?!(?>[^,]*?\bq=)0(?:\.0{1,3})?(?:\Z|[\s,;]))
[NC]
	RewriteRule \.html$ - [type=application/xhtml+xml;charset=UTF-8]
</IfModule>

- It will serve application/xhtml+xml when the Accept header is empty
(compatible with the current version of the W3C Validator, no
warning).

- When there is an Accept header, it will only serve
application/xhtml+xml when "application/xhtml+xml" is listed and with
a "q" higher than 0 (compatible with Internet Explorer, and of course
Opera, Firefox, Safari, etc., but not fully correct as it does not
check other q-values).


A little remark: when you use this rule in combination with a content
negotiation using a type-map (.var) for e.g. language negotiation, you
should add text/html AND application/xhtml+xml  in the .var file for
it to work as expected:

URI: index.fr.html
Content-language: fr
Content-type: text/html;qs=0.5

URI: index.fr.html
Content-language: fr
Content-type: application/xhtml+xml

URI: index.en.html
Content-language: en
Content-type: text/html;qs=0.5

URI: index.en.html
Content-language: en
Content-type: application/xhtml+xml

URI: index.en.html
Content-type: text/html;qs=0.5

URI: index.en.html
Content-type: application/xhtml+xml


You can test it live on http://alexandre.alapetite.net/

Cordially,
Alexandre Alapetite
http://alexandre.alapetite.net/cv/
Received on Monday, 21 April 2008 08:58:31 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 25 April 2012 12:14:29 GMT