In the message "Re: HEAD not well supported?", dated 10/3/07, Adam Taft wrote:

Aron Roberts wrote:
The HEAD method is identical to GET except that the server MUST NOT return a message-body in the response.

Would this also imply that the correct HTTP Status code to be returned from a HEAD request should be 204, corresponding in the Restlet framework to something like getResponse().setStatus( Status.SUCCESS_NO_CONTENT )?

NO! The whole point of HEAD is to emulate a GET request, except without returning the message body. You don't need to send 204 because, by definition, HEAD already means no content.

That makes sense: why return a status code indicating explicitly that no content is to be returned, since that may falsely imply that content in the entity body is sometimes allowed?

In that case, then, a status code of 200 would seem to be the only appropriate success response from an HTTP HEAD request. Status codes 201 through 203 appear to be inappropriate to HEAD requests, as well.

A call to HEAD should return _exactly_ the same headers as the same call to GET.

True. Responses to HEAD requests should return the same set of HTTP headers as responses to GET requests, except for the empty entity body.

As a slight refinement, however, responses to HEAD requests should not always return the range of status codes appropriate to GET requests. There are certain HTTP status codes are only appropriate to a specific HTTP method, or a subset of those methods. Specifically, there are some status codes that are appropriate to be returned in response to GET requests but not in response to HEAD requests.

I don't recall the Restlet framework placing any restrictions on what status codes an application developer chooses to return, however; we're able to shoot ourselves in the foot by returning totally inappropriate status codes if we wish.

Aron Roberts  Information Services and Technology . 2195 Hearst
              University of California, Berkeley, CA 94720-4876 USA
              [EMAIL PROTECTED] . +1 510-642-5974 . fax 510-643-5385
              http://purl.org/net/aron

Reply via email to