<?xml version="1.0" encoding="iso-8859-1"?>
<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw='http://wellformedweb.org/CommentAPI/' xmlns:dc='http://purl.org/dc/elements/1.1/' xmlns:rl='http://www.purl.org/RESTLog/'>
  <channel>
    <title>Content Negotiation Example</title>
    <link>http://wellformedweb.org/news/8</link>
    <description>
&lt;p&gt;Here is a client-side example Python script
that exploits the content negotiation in RESTLog.&lt;/p&gt;
&lt;div class="example"&gt;&lt;pre&gt;&lt;code&gt;
import urllib
# Simple test on WellFormedWeb.org to test the content
# negotiation. This file contains two tests. In each
# test a GET request is made against the URL
# http://WellFormedWeb.org, the only
# difference being in the ACCEPT header that is sent.
# In the first test the RSS file is returned,
# while in the second test the HTML file is
# returned.

op = urllib.FancyURLopener()
op.addheader('Accept', 'application/rss+xml')
f = op.open('http://wellformedweb.org/RESTLog.cgi')
s = f.read()
if (-1 != s.find("&amp;lt;description&gt;")):
    print "Success, we received an RSS file."
            
op = urllib.FancyURLopener()
op.addheader('Accept', 'text/html')
f = op.open('http://wellformedweb.org/RESTLog.cgi')
s = f.read()
if (-1 != s.find("&amp;lt;head&gt;")):
    print "Success, we received an HTML file."
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
</description>
    <dc:creator>BitWorking, Inc</dc:creator>
  </channel>
</rss>



