5 Apr 2012 cdent   » (Master)

content negotiation

Wikipedia says that content negotiation

is a mechanism defined in the HTTP specification that makes it possible to serve different versions of a document (or more generally, a resource) at the same URI, so that user agents can specify which version fit their capabilities the best.

TiddlyWeb uses content negotiation to allow a user agent to declare which representation of a resource it prefers. Using the Accept header the user agent can declare that it wants a text/plain, text/html or application/json version of a resource (if available). With plugins other representations can be made available.

Content negotiation is a very significant contributor making any HTTP API powerful and flexible.

A user agent (often a person using a web browser) may also adjust the request URL to add an extension to simulate setting the Accept header. For example to get the plain text representation of a bag resource one might request:

GET /bags/mybag.txt

The default available extensions are:

  • html to get text/html
  • txt to get text/plain
  • json to get application/json

TiddlyWebWiki adds:

  • wiki to get text/x-tiddlywiki

Not all resources provide all representations. See the HTTP API for details.

Supported extensions can be extended by creating and configuring another serialization in a plugin.

Syndicated 2012-04-05 17:39:55 (Updated 2012-04-05 17:40:36) from cdent

Latest blog entries     Older blog entries

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!