{"id":833,"date":"2012-03-07T09:39:37","date_gmt":"2012-03-07T09:39:37","guid":{"rendered":"http:\/\/blog.soton.ac.uk\/webteam\/?p=833"},"modified":"2012-03-07T09:40:34","modified_gmt":"2012-03-07T09:40:34","slug":"http-content-negoitation-could-do-better","status":"publish","type":"post","link":"https:\/\/blog.soton.ac.uk\/webteam\/2012\/03\/07\/http-content-negoitation-could-do-better\/","title":{"rendered":"HTTP Content Negoitation could do better"},"content":{"rendered":"<p>I&#8217;ve long been frustrated with HTTP content negotiation. It doesn&#8217;t do what I need.<\/p>\n<p>If you&#8217;ve never encountered this, when a web request is made there&#8217;s an optional header, something like<\/p>\n<p><code>Accept:text\/html,application\/xhtml+xml,application\/xml;q=0.9,*\/*;q=0.8<\/code><\/p>\n<p>Which says what formats the client (you) is able to accept, and it&#8217;s preferences. The <a href=\"http:\/\/www.gethifi.com\/blog\/browser-rest-http-accept-headers\">start of this blog post<\/a> gives a more full explanation. There&#8217;s also a way to negotiate what languages you prefer your content in, and a <a href=\"http:\/\/www.mementoweb.org\/guide\/quick-intro\/\">proposed system for asking for versions from a specific date or time<\/a>.<\/p>\n<p>My annoyance is specifically with the fact that what you ask for is very human-web-browser centric. You ask for formats your system is capable of accepting, not that you actually want. Why does this annoy me? Because if I have to give variations on the server a custom MIME Type, if I want to content negotiate for them specifically. All formats I work with are viewable as text, and most are XML, but if they have some wacky mimetype, like application\/x-southampton23 then nothing else will understand it as XML, which is just annoying. For example, an RSS1.0 feed is <code>application\/rss+xml<\/code>, according to StackOverflow. However it&#8217;s also valid <code>application\/rdf+xml<\/code>, <code>text\/xml<\/code> and <code>text\/plain<\/code>.<\/p>\n<h3>Servers should handle MIME-inherritance<\/h3>\n<p>I feel like content negotiation is missing a bit of inherritence. ie. If I ask for <code>text\/xml or <\/code><code>text\/html<\/code> and the server has only\u00a0<code>application\/x-southampton-xml-3 <\/code>available for that resource, then it should give me the <code>application\/rss+xml<\/code> document but tell me it&#8217;s <code>text\/xml,<\/code> which it is, and my web browser would display it as XML .<\/p>\n<p>Imagine the web-browser walking into a fancy resturant and ordering soup. The waiter brings over a dish and says, &#8220;here you are sir, Consomm\u00e9&#8221;. The browser refuses to eat it because it doesn&#8217;t know what &#8220;Consomm\u00e9&#8221; is.<\/p>\n<p>Now lets run that again, with a less pretentious waiter (in this analogy, the waiter is the web server). The soup is ordered and the waiter says &#8220;Here you are sir, Soup&#8221;. Which is not only true, but it&#8217;s certain to be understood by the customer, who eats their Consomm\u00e9 saying &#8220;mmm, nice soup&#8221;.<\/p>\n<h3>Servers should handle &#8216;abstract&#8217; MIME types<\/h3>\n<p>The other very useful thing would be to expect browsers to undersand abstract MIME types, which have no specific serialisation, but a number of sub variants. For example:<\/p>\n<p><code>Accept:application\/rdf+xml,application\/rdf;q=0.9<\/code><\/p>\n<p>Where <code>application\/rdf <\/code>is a super-class for all RDF serialisations. The above header line *should* say that I want RDF+XML, but failing that <em>any<\/em> RDF serialisation will do.<\/p>\n<h3>Research Data File Formats<\/h3>\n<p>Discribing the various properties of a file containing data as output from a research activity will also require some richers definitions, but maybe not in mime. I&#8217;m still thinking about this but I think it would be best to describe files, and sets-of-files, by things which they conform to. MIME Types could be part of this, but also what the data describes. For example; one record might require the following &#8216;tags&#8217; to be usefully discovered<\/p>\n<p>Single File, XML File, CML File, Describes Single Molecule, Describes Crystal, Describes Organic Crystal, Reuse License allows Attribution-Only reuse<\/p>\n<p>Admittedly chemists are already doing pretty well in this field, and maybe I&#8217;m trying to solve too general a case&#8230;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve long been frustrated with HTTP content negotiation. It doesn&#8217;t do what I need. If you&#8217;ve never encountered this, when a web request is made there&#8217;s an optional header, something like Accept:text\/html,application\/xhtml+xml,application\/xml;q=0.9,*\/*;q=0.8 Which says what formats the client (you) is able to accept, and it&#8217;s preferences. The start of this blog post gives a more [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0,"footnotes":""},"categories":[9430,18147],"tags":[],"class_list":["post-833","post","type-post","status-publish","format-standard","hentry","category-http","category-research-data"],"_links":{"self":[{"href":"https:\/\/blog.soton.ac.uk\/webteam\/wp-json\/wp\/v2\/posts\/833","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.soton.ac.uk\/webteam\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.soton.ac.uk\/webteam\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.soton.ac.uk\/webteam\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.soton.ac.uk\/webteam\/wp-json\/wp\/v2\/comments?post=833"}],"version-history":[{"count":4,"href":"https:\/\/blog.soton.ac.uk\/webteam\/wp-json\/wp\/v2\/posts\/833\/revisions"}],"predecessor-version":[{"id":837,"href":"https:\/\/blog.soton.ac.uk\/webteam\/wp-json\/wp\/v2\/posts\/833\/revisions\/837"}],"wp:attachment":[{"href":"https:\/\/blog.soton.ac.uk\/webteam\/wp-json\/wp\/v2\/media?parent=833"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.soton.ac.uk\/webteam\/wp-json\/wp\/v2\/categories?post=833"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.soton.ac.uk\/webteam\/wp-json\/wp\/v2\/tags?post=833"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}