[jifty-devel] Handling of responses to updates in REST

Andrew Sterling Hanenkamp sterling at hanenkamp.com
Wed Nov 28 18:03:24 EST 2007


Okay, this came up this afternoon while working with Shawn's handy
Net::Jifty utility. Basically, when you perform a PUT request to modify a
record, REST response to a successful modification by setting a "Location"
header that points back to the URL for viewing the resource. This doesn't
precisely make sense, at least not after reading and rereading RFC 2616 on
HTTP/1.1 and it doesn't seem to get consistent handling.

When I run the standalone Jifty server, for example, this gets treated as a
200 response with the header "Location: /=/model/SomeModel/id/123" set. This
is fine, other than being a violation of the absolute URL requirement here,
but it's pretty widely understood how relative URLs should be handled here.
However, when I run it under FastCGI (actually fcgid) on Apache, the
response is altered into a 302 response with the "Location" header.

After reading the HTTP spec carefully, I think the ideal handling would be
as follows:

On Create:

201 Created
Location: /=/model/SomeModel/id/123
Content-Location: /=/model/SomeModel/id/123

On Update

200 Updated
Content-Location: /=/model/SomeModel/id/123

In the first case, I might also have the Location: header attach the ".yml"
or other suffix if one was explicitly given in the request or not include
the "Location" header at all and let the user agent do whatever it wants
with the Content-Location header (in which relative URIs are okay).

I am sending this to the list because it's a change of behavior and I don't
want to kick anyone's puppy by changing it.

Cheers,
Andrew
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.bestpractical.com/pipermail/jifty-devel/attachments/20071128/150d3a9c/attachment.htm


More information about the jifty-devel mailing list