Re: What is the correct way to do content negotiation?

Azu wrote:
> Basically, what I'm wandering is, how am I supposed to do content 
> negotiation? At first I thought that I was supposed to use the 
> HTTP_ACCEPT header

In general, you are. (Although you should parse it according to the 
spec, and not use one of the overly common scripts that assume that 
because the string of characters "applications/xhtml+xml" appears in the 
header that XHTML is accepted and is preferred to anything else you 
might offer.

, but when I use your validator script at
> validator.w3.org <http://validator.w3.org> to try to test my website in 
> different content types (by using the doctype option), it doesn't change 
> anything in the HTTP_ACCEPT header.

The Doctype Override tells the validator to download the document and 
then change the Doctype (or add one if one is not already present).

Presently the validator does not provide a means to specify accept headers.

> P.S. on a completely different topic; how do I change the options in 
> your validator script without it re-downloading my web page? Like for 
> example if I want to enable verbose output, how do I have it do this 
> without it downloading the page from my server again?

This feature is also not available. In theory a patch could be written 
to enable caching, but I suspect it would cause more problems then it 
would solve given the common sequence of:

1. Test with validator
2. Edit document
3. Go to 1

If a retest used cached data instead of the newly edited data then I 
would expect a lot of people to be confused.

-- 
David Dorward                               <http://dorward.me.uk/>

Received on Wednesday, 6 August 2008 12:11:35 UTC