Re: XHTML2 MIME type

Toby A Inkster / 2003-04-11 19:40:

> On Fri, Apr 11, 2003 at 04:01:57PM +0200, Bjoern Hoehrmann wrote:
> | Indeed, but using the XHTML 1.0 media type for incompatible XHTML 2.0
> | documents could be a major hindrance to early adopters of XHTML 2.0,
> | since it would be rather hard if not impossible to determine whether
> | the user agent supports XHTML 2.0 on the server side. 
> 
> This is already the case. The Accept header is simply not a reliable way 
> of determining which user agents can handle XHTML 1.1. e.g. Opera 6 and 
> above can handle it, but they don't say so in the Accept header. OTOH, 
> most browsers seem to list */* in the Accept header, which suggests they 
> will accept application/xhtml+xml!
> 
> Currently, I just use something along the lines of:
> 
> if ( ($ua =~ m/Opera.7/) || ($su =~ m/Gecko/) ) {
> 	print "Content-Type: application/xhtml+xml\n\n";
> } else {
> 	print "Content-Type: text/html\n\n";
> }
> # now send the xhtml 1.1 document

OK. How about you check if the Accept header explicitly lists 
application/xhtml+xml like for example Gecko does. This way also 
those Opera and Gecko users that have modified their user agent 
string will get the full content.

Another way to go for it -- and I think this is a better way -- is 
to actually compute the correct version. If the Accept header 
doesn't define q-values for any type, consider all explicit MIME 
types as q=1.0, all types with one star (e.g. image/*) as q=0.25 and 
*/* as q=0.05. If the version with application/xhtml+xml still seems 
to be the best one, then send it. This way the user agent should get 
the type it *really* can display or the best type you've available 
for offline viewing.

-- 
Mikko

Received on Friday, 11 April 2003 14:35:49 UTC