Universal Subscription Mechanism

Author

Randy Charles Morin, KBCafe.com

Version

Latest Version: http://www.kbcafe.com/rss/usm.html

Fri, Aug 5 2005 (version 1.7) - Atom 1.0
Fri, Jun 24 2005 (version 1.6) - Registry Entries.
Sun, Feb 27 2005 (version 1.5) - Update on Vendors.
Fri, Feb 4 2005 (version 1.4) - General update on Vendors, Samples, Bugs, Thank yous.
Wed, Jan 19 2005 (version 1.3) - Table of Content
Wed, Jan 19 2005 (version 1.2) - Add Reflexive Auto-Discovery, Samples, Vendors
Tue, Jan 18 2005 (version 1.1) - Switched to Atom Link Construct
Fri, Jan 14 2005 (version 1.0)

Status

Stable

Table of Contents

  1. Description
  2. Content-Type
  3. Atom Link Construct
  4. Reflexive Auto-Discovery
  5. Sample Client Code
  6. Vendor Support
  7. RSS Versions
  8. Atom Draft
  9. Thanks

Description

Universal Subscription Mechanism is a really simple way of allowing RSS readers to subscribe to RSS feeds. Many blogs and Websites with RSS feeds present an orange XML or RSS button, Atom button or text anchor link that points to the RSS feed. When the user clicks on the button, nothing substantial happens. This mechanism replaces that click with a subscription notification to the users default RSS handler.

The mechanism defines two requirements of the RSS feed publisher; to return the application/rss+xml Content-Type in the HTTP headers and to place one new Atom Link Construct element in the RSS channel. The mechanism then allows RSS readers to create a simple shell extension to initiate the RSS feed subscription using a small native application.

Content-Type

In order for Universal Subscription Mechanism to work, the RSS publisher must return the application/rss+xml media type in the HTTP Content-Type header. RSS publishers currently return a variety of media types; text/xml, application/xml, among others.

The next listing has an example HTTP header for an RSS response that is not Universal Subscription capable.

HTTP/1.1 200 OK 
Content-Length: 46412
Content-Type: text/xml
Date: Fri, 14 Jan 2005 20:59:01 GMT

The Content-Type is text/xml. This will NOT work. For Universal Subscription Mechanism to work, you must change the Content-Type header to return the application/rss+xml media type.

The next listing has an example HTTP header for an RSS response that returns the proper media type for Universal Subscription Mechanism.

HTTP/1.1 200 OK 
Content-Length: 46673
Content-Type: application/rss+xml
Date: Fri, 14 Jan 2005 21:02:39 GMT

RSS readers should note that some RSS publishers will set the Content-Type to "application/rdf+xml". I would discourage this practice, as it would create some confusion, but respect that others may have a different opinion than me. Therefore, it is specifically allowed, but strongly discouraged.

Atom Link Constructs

The Atom Link Constructs defines a way of adding addition URIs to an RSS feed. We are will use this construct to embed the subscription URL into the RSS feed itself. This allows a RSS reader to determine the subscription URL of an RSS feed. This element is important for the Universal Subscription Mechanism because it is not always possible to determine the subscription URL from the RSS file. The RSS file may have been downloaded and saved in a new location.

Namespace Change
The Atom format deprecated it's version 0.3 format. USM clients may want to check for the current and legacy Atom namespaces. The version 1.0 namespace is "http://www.w3.org/2005/Atom". The deprecated version 0.3 namespace is "http://purl.org/atom/ns#". The content of the Atom Link Construct remains the same in both formats.

Example

<atom:link 
rel="self"
type
="application/rss+xml"
title
="The RSS Blog"
href
="http://www.kbcafe.com/rss/rss.xml"
xmlns:atom
="http://www.w3.org/2005/Atom" />

The Atom link construct element must be a child of the RSS channel element.

rel Attribute

Two values are allows in the rel attribute for discovering the subscription URL from XML. The value "self" is preferred, as it matches the accepted Atom implementation. The value "start" is also acceptable to remain backwards compatible with the original Atom implementation.

type Attribute

The type attribute is the proper media type for RSS; applicaton/rss+xml. This media type is not registered, but I hope to change this in the near future. RSS readers should expect that some RSS publishers will set the type in the link module element to "application/rdf+xml". I would discourage this practice, as it would create some confusion, but respect that others may have a different opinion than me. Therefore, it is specifically allowed.

title Attribute

The title attribute should be set to the title of the RSS channel. RSS readers can safely ignore this attribute.

href Attribute

The href attribute is the subscription URL. It may be different than the originating URL, but should be the same as the originating URL.

The <channel/atom:link> Bug

Some RSS readers retrieve the <channel/link> element without regard to the namespace of the link element. Further, they may assume that the element contains textual content; the HTML URL of the channel. This may cause some RSS readers to fail when the <channel/atom:link> element is present. This is a bug in the RSS reader. In order to avoid such failures, the RSS publisher may place the <channel/link> text within the <channel/atom:link> element. An example follows.

<channel>
<title>The RSS Blog</title>
<description>Really Simple Syndication</description>

<link>http://www.kbcafe.com/rss/</link>


<atom:link
rel="self"
type
="application/rss+xml"
title
="The RSS Blog"
href
="http://www.kbcafe.com/rss/rss.xml"
xmlns:atom
="http://www.w3.org/2005/Atom" >http://www.kbcafe.com/rss/</atom:link>
...
</channel>

Reflexive Auto-Discovery

There is a second mechanism that's not as good as the Atom Link Construct but serves the same purpose. If your RSS feed's channel/link points to an HTML Webpage that has RSS feed discovery, then this second method can be used in place of the Atom Link Construct.

Example

Looking at The RSS Blog, the RSS feed starts as follows...

<?xml version="1.0" encoding="utf-8" ?> 
<rss version="2.0">
<channel>
<title>The RSS Blog</title> 
<link>http://www.kbcafe.com/rss/</link>

The channel/link element in this feed point to http://www.kbcafe.com/rss/. Now, if you visit that page, then you'll note the HTML <head> has the following link element...

<link rel="alternate" type="application/rss+xml" title="RSS" href="http://www.kbcafe.com/rss/rss.xml">

This is what I call reflexive auto-discovery. The feed, points to the blog, points to the feed. So, we can always find where the feed originated, even after we've moved it. This can also serve as verification that the feed content actually belongs to the blog specified in its channel/link.

Why is Atom Link Construct Better than Reflexive Auto-Discovery?

It's inevitable that this question will be asked. The answer lies in understanding how a browser, for example Internet Explorer, launches applications based on the Content-Type. IE makes a temporary copy of the file and passes that file name to the program associated with the Content-Type. Note, that it does not pass the original URL, but rather the temporary filename. If you can discover the feed URL in the feed, then you've accomplished USM with one HTTP GET. If Atom Link Construct is not implemented, then the algorithm falls back and performs a second HTTP GET on the Webpage in the channel/link element. It's one HTTP GET versus two HTTP GETs.

Further, it's not always possible to implement Reflexive Auto-Discovery as the author of the RSS feed may not also be the author of the Webpage in the channel/link element. In this case, the Atom Link Construct is the better and only solution.

Sample Client Code

If you want me to point to your own source code, with attribution, then please send me an email and a link. I'm looking for PHP, Python and Java implementation in particular, but any submissions would be appreciated.

C#

I've written some sample C# client code for Reflexive Auto-Discovery and Universal Subscription Mechanism. The USM reference implementation has support for 20 RSS readers and aggregators. Download the USM client installer.

Python

Mike Rowehl has written a Python-based USM handler for Firefox/Linux for Bloglines.

Windows Registry

The following Registry entries are used to associated the application/rss+xml Content-Type to the .rss file extension and the .rss file extension to your application. You can override various sets of these Registry entries to implement USM. The HKEY_CURRENT_USER entries will override the HKEY_CLASSES entries to allow for user preferences.

HKEY_CLASSES_ROOT\MIME\Database\Content Type
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.rss\OpenWithProgids
HKEY_CURRENT_USER\Software\Classes\.rss\shell\open\command
HKEY_CLASSES_ROOT\.rss
HKEY_CLASSES_ROOT\rssfile\shell\open\command

Download the latest version of the Juice News Reader.
View a screencast of Juice in action.
Juice Screencast

Vendor Support

The following software has support for the Universal Subscription Mechanism.

The following software has USM in the plans.

The following software has instruction for implementing USM.

If you want me to point to your software, code samples or help instructions, then please send me an email and a link.

RSS Versions

The Universal Subscription Mechanism applies equally well to all versions of RSS, except of course, Atom, which already has its own subscription mechanism  and RSS 0.91 which is not extensible.

Warning: rel='self' is invalid in Atom 0.3

Use rel='self' in Atom 1.0 and later and rel='start' in Atom 0.3. As an USM client, you should look for all alternatives.

Atom Draft

The Universal Subscription Mechanism is based on a draft version of the Atom syndication format. If the Atom link construct changes before final publication, then this mechanism may also change. At this moment, there is no change in Atom link construct that is expected to affect the Universal Subscription Mechanism.

Thanks

Thanks go to Joe Gregorio who is the original author of this vision. This entire document is simply a restatement of his Atom subscription mechanism, but for RSS and Atom. Thanks Joe! Thanks go to Dave Winer for asking for a universal solution to what he called, The Yahoo! Problem. Thanks Dave! Thanks go to Adam Kalsey who did most of the pushing for this solution in his article Handling RSS in the browser and Danny Ayers for spreading the meme with Life, the Universe and Feed Subscription. Thanks Adam and Danny! Thanks also to Eric Lunt for enabling USM on 30 thousand blogs (and growing) with FeedBurner and for identifying and solving the <channel/atom:link> bug.