Comments on: From the Top: MIME and Content Negotiation http://www.thatstandardsguy.co.uk/blog/2006/01/16/content-negotiation/ a web developer with standards Mon, 01 Jun 2009 17:48:42 +0000 http://wordpress.org/?v=2.7.1 hourly 1 By: Torsten http://www.thatstandardsguy.co.uk/blog/2006/01/16/content-negotiation/comment-page-1/#comment-47 Torsten Tue, 17 Jan 2006 01:33:59 +0000 http://www.thatstandardsguy.co.uk/2006/01/13/from-the-top-content-negotiation/#comment-47 Neil, my apologies. I've just looked over your script again and I realise I was reading it all wrong. Your initial stristr search for the string application/xhtml+xml is sufficient, and the reg exp only comes in to play if a q value of anything less than 1 is specified in the accept header. The logic threw me initially, but I see now that it would work perfectly well. Neil, my apologies. I've just looked over your script again and I realise I was reading it all wrong. Your initial stristr search for the string application/xhtml+xml is sufficient, and the reg exp only comes in to play if a q value of anything less than 1 is specified in the accept header. The logic threw me initially, but I see now that it would work perfectly well.

]]>
By: Karl Dawson http://www.thatstandardsguy.co.uk/blog/2006/01/16/content-negotiation/comment-page-1/#comment-46 Karl Dawson Mon, 16 Jan 2006 21:38:19 +0000 http://www.thatstandardsguy.co.uk/2006/01/13/from-the-top-content-negotiation/#comment-46 Update to article: Clarified and expanded on the fact that the <abbr title="Extensible Markup Language">XML</abbr> Declaration and XML-stylesheet reference (along with the DOCTYPE) are part of the <abbr title="Extensible Markup Language">XML</abbr> Prolog - and how to write each part. Clarified that ' is unsupported in <abbr title="Hypertext Markup Language">HTML</abbr> 4. Reworked <abbr title="Hypertext Markup Language">HTML</abbr> comments in scripts. Added Point 11 in "Doing the Right Thing" section. My thanks to Lachlan Hunt, Jukka K. Korpela, <a href="http://sitesurgeon.co.uk/" rel="nofollow">Ben Millard</a> and Torsten (above and forum member at <a href="http://www.accessify.com" rel="nofollow">Accessify.com</a>) Update to article:

Clarified and expanded on the fact that the XML Declaration and XML-stylesheet reference (along with the DOCTYPE) are part of the XML Prolog - and how to write each part.

Clarified that &apos; is unsupported in HTML 4.

Reworked HTML comments in scripts.

Added Point 11 in "Doing the Right Thing" section.

My thanks to Lachlan Hunt, Jukka K. Korpela, Ben Millard and Torsten (above and forum member at Accessify.com)

]]>
By: Torsten http://www.thatstandardsguy.co.uk/blog/2006/01/16/content-negotiation/comment-page-1/#comment-43 Torsten Mon, 16 Jan 2006 20:30:57 +0000 http://www.thatstandardsguy.co.uk/2006/01/13/from-the-top-content-negotiation/#comment-43 Hi Neil, As I say, I'm not an expert, but I am rather surprised that it works. The accept header for Firefox 1.07 under GNU/Linux is as follows - <pre><code>text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5</code></pre> ...your regular expression doesn't match anything in that string. By my understanding your script would therefore serve text/html to Firefox when, according to its accept header anyway, it prefers application/xhtml+xml. I just had a look at Simon's article and his reg exp seems much better. It is in fact very similar to the one I use myself: <code>$htmlmimetype = '/text\/html(?:;q=([01](?:\.\d{1,3})?))?/i'; $xhtmlmimetype = '/application\/xhtml\+xml(?:;q=([01](?:\.\d{1,3})?))?/i';</code> ...so I would say that wouldn't I ;o) Hi Neil,

As I say, I'm not an expert, but I am rather surprised that it works.

The accept header for Firefox 1.07 under GNU/Linux is as follows -

text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5

...your regular expression doesn't match anything in that string. By my understanding your script would therefore serve text/html to Firefox when, according to its accept header anyway, it prefers application/xhtml+xml.

I just had a look at Simon's article and his reg exp seems much better. It is in fact very similar to the one I use myself:

$htmlmimetype = '/text\/html(?:;q=([01](?:\.\d{1,3})?))?/i';
$xhtmlmimetype = '/application\/xhtml\+xml(?:;q=([01](?:\.\d{1,3})?))?/i';

...so I would say that wouldn't I ;o)

]]>
By: Neil Crosby http://www.thatstandardsguy.co.uk/blog/2006/01/16/content-negotiation/comment-page-1/#comment-42 Neil Crosby Mon, 16 Jan 2006 19:17:36 +0000 http://www.thatstandardsguy.co.uk/2006/01/13/from-the-top-content-negotiation/#comment-42 And yes, my article is based on Simon's original work - it wouldn't have been written if he hadn't done his stuff first. And yes, my article is based on Simon's original work - it wouldn't have been written if he hadn't done his stuff first.

]]>
By: Neil Crosby http://www.thatstandardsguy.co.uk/blog/2006/01/16/content-negotiation/comment-page-1/#comment-41 Neil Crosby Mon, 16 Jan 2006 19:16:09 +0000 http://www.thatstandardsguy.co.uk/2006/01/13/from-the-top-content-negotiation/#comment-41 Thanks for the link through to my article Karl - it was a nice surprise to come home from work to. Torsten: I can't recall my exact thinking behind using that regex in that way, but what I can say is that I've been using that script (or versions of it) for about two years now, and I haven't had it blow up in my face yet. I've just had a quick play with Firefox, changing "network.http.accept.default" (vie about:config) to contain various different q-values and I couldn't get the script to do anything unexpected. <strong>However</strong> I am not convinced that you don't (whoa, too many negatives there) have a point, so I'm going to go back and have a proper look at the script later in the week. Thanks for the link through to my article Karl - it was a nice surprise to come home from work to.

Torsten: I can't recall my exact thinking behind using that regex in that way, but what I can say is that I've been using that script (or versions of it) for about two years now, and I haven't had it blow up in my face yet.

I've just had a quick play with Firefox, changing "network.http.accept.default" (vie about:config) to contain various different q-values and I couldn't get the script to do anything unexpected. However I am not convinced that you don't (whoa, too many negatives there) have a point, so I'm going to go back and have a proper look at the script later in the week.

]]>