[annotator-dev] Yet Another Store Implementation (Ruby/Rails)

Nick Stenning nick at whiteink.com
Mon Nov 3 17:36:56 UTC 2014



On Mon, Nov 3, 2014, at 06:57, Benjamin Young wrote:
> Great work, King'ori!
> 
> I agree with your analysis that 303 See Other isn't quite the right
> message.

There's nothing wrong with using 303 to refer the client to the newly
created resource. Indeed, that's exactly the intended use of 303[1].
You'd POST to a create action, and receive

    HTTP/1.1 303 See Other
    Location: /annotations/123

to direct the client to the new resource[2]. The only reason the store
implementation doesn't do this is because browsers didn't correctly
propagate CORS headers and authorisation across the redirect at the
time.

It's ok to return 201 from the POST action, but the semantics,
particularly around caching, are a bit messy. The body of the response
in the case of a POST should not, strictly, be a representation of the
resource created, as its URI is not the URI of the POST endpoint. So, if
you return a 201, you should refer to the newly created resource in a
Location header (as with a 303) with the disadvantage that browsers
won't interpret this as a redirect.

-N

[1]: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.4
[2]: https://en.wikipedia.org/wiki/HTTP_303



More information about the annotator-dev mailing list