<?xml version="1.0" encoding="utf-8"?>
<!-- generator="Blooki/0.4803" -->
<rdf:RDF
  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
  xmlns:admin="http://webns.net/mvcb/"
  xmlns:cc="http://web.resource.org/cc/"
  xmlns="http://purl.org/rss/1.0/"
>

<channel rdf:about="http://blooki.org/2004/10/13/.rdf/">
  <title>Blooki</title>
  <link>http://blooki.org/2004/10/13/.rdf/</link>
  <description>Grow what you know</description>
  <dc:language>en</dc:language>
  <dc:creator>Paul Kulchenko</dc:creator>
  <dc:date>2004-10-13T21:46:00Z</dc:date>
  <admin:generatorAgent rdf:resource="http://www.blooki.org/" />

  <items>
    <rdf:Seq>
      <rdf:li rdf:resource="development/content-negotiation"/>
    </rdf:Seq>
  </items>
</channel>


  <item rdf:about="http://blooki.org/2004/10/13/.rdf/development/content-negotiation">
    <title>Content negotiation</title>
    <link>http://blooki.org/2004/10/13/.rdf/development/content-negotiation</link>
    <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>
    <dc:subject>development/</dc:subject>
    <dc:date>2004-10-13T21:46:00Z</dc:date>
  </item>


</rdf:RDF>
