Re: PUT and extensions

On Wed, 4 Apr 2012 19:04:25 +0200
Henry Story <henry.story@bblfish.net> wrote:

> If I PUT foaf.ttl
> should a GET foaf.rdf then succeed?

If you PUT foaf.ttl, there's no guarantee that GET foaf.ttl (sic!) will
succeed.

Even if the server accepts and actions your PUT request, it may decide
to choose a different name for the resource than the one you wanted; or
it may be accepted and then promptly deleted before you GET it; or it
may be accepted, but require a higher authorization level than yours to
GET.

WWW::DataWiki has a list of supported extensions that it will recognise
in a URL - but these are essentially just shortcuts for assigning an
Accept header. (If you deviate from the supported list, you'll just get
a 404.)

You could:

	PUT /foo.ttl HTTP/1.1
	Content-Type: application/rdf+xml

	<rdf:RDF><rdf:Description rdf:about="" rdf:value="" /></rdf:RDF>

And you'd get a response like this:

	HTTP/1.1 202 Accepted
	Content-Type: text/turtle

	<> rdf:value "" .

(I'm ignoring namespace/prefix definitions here.) Why? Well, it makes
more sense if you "expand" the shortcut for the Accept header:

	PUT /foo HTTP/1.1
	Content-Type: application/rdf+xml
	Accept: text/turtle

	<rdf:RDF><rdf:Description rdf:about="" rdf:value="" /></rdf:RDF>

So it parses the RDF/XML in the body based on the Content-Type header;
creates or updates the resource "/foo"; and then serves a
representation of "/foo" as Turtle.

-- 
Toby A Inkster
<mailto:mail@tobyinkster.co.uk>
<http://tobyinkster.co.uk>

Received on Wednesday, 25 April 2012 09:36:31 UTC