1

When doing a PUT or DELETE with an "If-Match" header, in case the ETag sent by a client indicates staleness, rather than just returning a 412, I'd like to return the whole up-to-date entity (including its new ETag in the HTTP header), so the client does not have to perform another GET round trip, which they otherwise would certainly do - in my use-case at least they'd do in probably 100% of the cases.

I don't see anything for or against it in the docs for 412: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.13

And looking at, say, status code 409, it doesn't seem to be a problem in general to do whatever one likes with the response body of a 4xx error: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.10

So, does anything (especially in the HTTP specs) speak against return the full up-to-date entity and its ETag?

Charles
  • 50,943
  • 13
  • 104
  • 142
Evgeniy Berezovsky
  • 18,571
  • 13
  • 82
  • 156

2 Answers2

1

Should be fine:

All 1xx (informational), 204 (no content), and 304 (not modified) responses MUST NOT include a message-body. All other responses do include a message-body, although it MAY be of zero length.

Source: http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.3

Evgeniy Berezovsky
  • 18,571
  • 13
  • 82
  • 156
0

What is the request? GET with If-None-Match? In that case, the server isn't supposed to return 412 anyway.

For PUT, DELETE, you certainly can return the current representation. For large representations, it will be inconvenient for clients that don't need it though.

You may also want to label the payload as representation of the resource by using the Location header; see http://greenbytes.de/tech/webdav/draft-ietf-httpbis-p2-semantics-16.html#identifying.response.associated.with.representation.

Julian Reschke
  • 40,156
  • 8
  • 95
  • 98
  • You kind of answered the "is it a GET...?" question yourself, but I clarified in my question what exactly I'm talking about, which should make it easier to understand. Understandability aside, if I'm talking about 412 and stale ETags, wouldn't PUT and DELETE (and maybe POST, although I don't use it) + If-Match be the only things I could be talking about? (Non-rhetorical question) – Evgeniy Berezovsky Sep 15 '11 at 01:41
  • Thanks for the 'Location' header hint. Not sure though if it is useful for any consumer of the service, as if they know how to PUT or DELETE a resource, they certainly know how to GET it. I edited your post and added a reference to the RFC part that specifies when it's OK to send a response body and when it's not. That's something I was (also) interested in. Will accept your answer when you accept the edit (or provide some other reference to something 'official' that people can check to verify your claims). – Evgeniy Berezovsky Oct 03 '11 at 02:02