Fortune REST Service

This is an AJAX service which returns the text from the fortune program. There are three return types:


    

The XMLHTTPRequest can return either a responseText or a responseXML. If the service is accessed with a higher Accept priority for text/plain then text is returned. If text/xml has a higher priority or */* is the only match then XML is returned, with the fortune is wrapped in <fortune> tags.

XML.com recommends also supporting a mimeType parameter and that makes sense to me. There could be times you are only able to specify a URI, like maybe with an RSS feed. It is also handy for user agents like Konqueror whose version of setRequestHeader on appends to the accepted list.

I also added support for a X-Accept-Namespace HTTP request header to be able to handle different types of XML. It is currently simply an alternate method for specifying application/rss+xml.

There is a sample AJAX script to access this service in this page. Either the text/plain, text/xml or application/rss+xml.

Known bugs: