http-status-codes

Comprehensive list of HTTP status codes that don't include a response body


I have discovered that some HTTP status codes, like 304, contain no message body and are terminated by CRLF.

Is there a comprehensive list of such codes? So far I have got: 100-199, 204, and 304. Are there any others?

I am concerned with message delimiting with persistent connections, i.e., where does one HTTP message stop and the next begin?


Solution

  • A body is optional for all the 4xx error codes:

    Except when responding to a HEAD request, the server SHOULD include an entity containing an explanation of the error situation, and whether it is a temporary or permanent condition.

    Same for the 5xx:

    Except when responding to a HEAD request, the server SHOULD include an entity containing an explanation of the error situation...

    (SHOULD means that really, they should, but it's not a MUST.)

    The 1xx messages don't contain a body as far as I can tell. 201 (in addition to 204 and 205) doesn't have to have a body. The 3xx are a mixed bag, but a body is optional for a lot of them.

    Source: HTTP/1.1: Status Code definitions.

    The rules for message length information are described in HTTP Message - 4.4 Message Length. It's not exactly trivial.