<?xml version="1.0" encoding="utf-8"?>
<!-- generator="Blooki/0.4803" -->
<rss version="2.0">
  <channel>
    <title>Blooki</title>
    <link>http://blooki.org/2004/10/13/.rs2/</link>
    <description>Grow what you know</description>
    <language>en</language>
    <copyright>Copyright 2010</copyright>
    <lastBuildDate>Wed, 13 Oct 2004 21:46:00 GMT</lastBuildDate>
    <pubDate>Wed, 13 Oct 2004 21:46:00 GMT</pubDate>
    <generator>http://www.blooki.org/</generator>
    <ttl>60</ttl>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs> 


  <item>
    <title>Content negotiation</title>
    <description>&lt;p&gt;As Ian Hickson explained, &lt;a href="http://www.hixie.ch/advocacy/xhtml"&gt;Sending &lt;span class="caps"&gt;XHTML &lt;/span&gt;as text/html considered harmful&lt;/a&gt;, but it's fine "send &lt;span class="caps"&gt;XHTML &lt;/span&gt;as application/xhtml+xml to UAs that support it, and as text/html to legacy UAs."&lt;/p&gt;

&lt;p&gt;To implement this I've extended the content-type parameter in template, so that instead of &lt;code&gt;text/html&lt;/code&gt; it is now possible to write &lt;code&gt;application/xhtml+xml,text/html&lt;/code&gt;. Server will then use &lt;code&gt;Accept&lt;/code&gt; header to identify what content type should be served; it will serve &lt;code&gt;application/xhtml+xml&lt;/code&gt; to Firefox and &lt;code&gt;text/html&lt;/code&gt; to InternetExplorer. It also applies to &lt;span class="caps"&gt;RSS &lt;/span&gt;content types: Atom template has &lt;code&gt;application/atom+xml,application/xml&lt;/code&gt; as the content type.&lt;/p&gt;

&lt;p&gt;All this is done by the following lines of code (thanks to Gisle Aas for his &lt;span class="caps"&gt;HTTP&lt;/span&gt;::Negotiate):&lt;/p&gt;

&lt;pre&gt;&lt;code&gt; my @types = split /,/, $template-&amp;gt;content_type;
 my $pos = 0; # ::Negotiate sorts results by quality and then by size (asc)
 my $variants = [map {[$_, 1, $_, (undef) x 3, ++$pos]} reverse @types];
 my $headers = new HTTP::Headers Accept =&amp;gt; $request-&amp;gt;cgi-&amp;gt;http('accept');
 my $type = HTTP::Negotiate::choose($variants, $headers) || pop @types;&lt;/code&gt;&lt;/pre&gt;</description>
    <guid>http://blooki.org/2004/10/13/.rs2/development/content-negotiation</guid>
    <category>development/</category>
    <pubDate>Wed, 13 Oct 2004 21:46:00 GMT</pubDate>
  </item>


  </channel>
</rss>
