Monthly Archives: March 2007

The Semantics of 301 Moved Permanently

Section 10.3.2 of RFC2616 describes the HTTP status code 301 Moved Permanently. The first paragraph explains that the status code means that:

The requested resource has been assigned a new permanent URI and any future references to this resource SHOULD use one of the returned URIs. Clients with link editing capabilities ought to automatically re-link references to the Request-URI to one or more of the new references returned by the server, where possible.

I was musing recently about the semantics of this response from an RDF perspective. Essentially we have a resource (/resource/a) which has been assigned a new permanent URI (e.g. /resource/b) and clients are licensed to treat all references to the old resource as references to the new.
It occured to me that this essentially means that the two URIs can be considered to be the same resource, i.e.:

</resource/a> owl:sameAs </resource/b> .

Using the HTTP Vocabulary in RDF (actually, the 1st March 2007 editors draft) we can write down an HTTP request and response like this:

<http:GetRequest rdf:ID="req0">
<http:requestURI rdf:resource=""/>
<http:response rdf:resource="#resp0"/>
<http:Response rdf:ID="resp0">
<http:responseCode rdf:resource=""/>
<http:location rdf:resource=""/>

I’m playing a bit loose with the http:requestURI property here as the specification states that it should have a literal value; although I’m not sure why as a URI is much more useful.
Now that we have an example GET and subsequent 301 response expressed in RDF, we can state the owl:sameAs semantics using rules. The following uses the Jena rules syntax:

@prefix rdf: <;.
@prefix http: <;.
@prefix owl: <;.
[MovedPermanently: (?request http:requestURI ?originalResource),
(?request http:response ?response),
(?response http:responseCode http:301),
(?response http:location ?newResource)
(?originalResource owl:sameAs ?newResource)]

The example document and rules are online, so you can test them using the xmlarmyknife rules engine, like this.
What do you think? Is this interpretation OK?


Get every new post delivered to your Inbox.

Join 30 other followers