Which HTTP status codes are defined to carry no response content, and what goes wrong on the wire if a server writes body bytes with a 204 No Content or 304 Not Modified?
answer
- bodiless: all 1xx, 204, 205, 304
- HEAD never has content, any status
- header section ends the message
- extra bytes = next response on keep-alive
- 205 = reset the form, not 204-plus
basics
~20 sAll 1xx responses plus 204 No Content, 205 Reset Content and 304 Not Modified never carry content; neither does any response to HEAD. Extra body bytes desynchronize an HTTP/1.1 connection: the recipient reads them as the start of the next response.
solid answer
~50 sBodiless by definition: every **1xx**, **204 No Content**, **205 Reset Content** and **304 Not Modified**. Independently, a response to **HEAD** never has content whatever its status, and a 2xx to CONNECT ends the HTTP message. 204 means "succeeded, and there is deliberately nothing to send" — typical for a successful DELETE or a PUT whose result the client already holds. 205 additionally asks the user agent to reset the document view, e.g. clear a form for the next entry. In HTTP/1.1 the danger is framing. A recipient does not consult `Content-Length` for these codes — it knows the message ends with the headers. If the server writes five extra bytes, the peer reads them as the beginning of the next response on that persistent connection. The result is corrupted pipelining, garbled responses through a proxy, and in the adversarial case request/response smuggling. Well-behaved servers and frameworks silently drop content written on a 204.
code
http · 5 linesDELETE /v1/sessions/8f3a HTTP/1.1
Host: api.example.com
HTTP/1.1 204 No Content
Date: Tue, 12 Aug 2026 09:14:02 GMTgo deeper
List the bodiless codes — 1xx, 204, 205, 304 — and that HEAD responses never carry content.
Explain that the status code, not Content-Length, determines framing for these codes, and what 205 actually instructs.
Connect it to real failures: connection desynchronization under keep-alive, proxy corruption and response-splitting risk, plus why frameworks strip such bodies.
Argue for framing correctness as a security property at the edge — h1/h2 translation reintroduces the hazard — and for owning length headers in the platform layer rather than in handlers.
## Which responses have no content HTTP distinguishes what a status code *means* from how a message is *framed*. Four situations produce a message with no content at all: 1. **Any 1xx interim response.** An interim ends at the end of its header section by definition. 2. **204 No Content.** The request succeeded and the server intentionally has nothing to return. Header fields may still carry useful metadata (`ETag`, cache headers, pointers). 3. **205 Reset Content.** Like 204, plus a request that the user agent reset the document view that caused the request — historically "clear the form so the operator can type the next record". It is rare in modern APIs. 4. **304 Not Modified.** The client's cached representation is still valid, so sending the bytes again would defeat the purpose. A 304 may echo header fields that would have appeared on the 200 (validators, cache directives, `Vary`), but transmits no content. Two further cases are about the request, not the code: a response to **HEAD** never has content whatever its status, and a successful response to **CONNECT** switches the connection to tunnelling. ## Why the framing matters HTTP/1.1 is a byte stream over a reused connection. The parser must know exactly where one message ends and the next begins. Normally that comes from `Transfer-Encoding: chunked` or `Content-Length`. For the bodiless codes the rule is stronger: the recipient knows the message ends at the header section and does **not** treat a `Content-Length` as a promise of bytes to come. So when a buggy server emits a `204 No Content` with `Content-Length: 5` followed by five bytes, the peer has already finished the response at the blank line. Those five bytes are now interpreted as the first bytes of the *next* response. On a persistent, pipelined or proxied connection that means one client can receive another client's data, or an attacker can plant a synthetic response — the class of bug known as response splitting or desynchronization. This is why frameworks and reverse proxies aggressively strip content written alongside a 204, and why intermediaries may drop a `Content-Length` on these codes. HTTP/2 and HTTP/3 are safer here because framing is explicit: content lives in DATA frames and a bodiless response simply ends the stream with END_STREAM on HEADERS. Sending DATA anyway is a protocol error on that stream rather than a corruption of everything after it — but the semantics are identical, and an intermediary translating h2 to h1 can reintroduce the h1 hazard. ## 204 versus 200 with an empty body Both are legal. `200 OK` with `Content-Length: 0` says "here is the representation, and it happens to be empty"; `204` says "there is no representation to send at all". Both are defined as cacheable by default, so the difference is semantic, not a caching trick. The practical divide is client behaviour: many HTTP clients and browser `fetch` wrappers will try to parse an empty 200 body as JSON and throw, while 204 is handled as a distinct no-content case. And `205` should never be used as "204 but fancier" — it carries a real instruction to reset the view, which almost no API client implements. ## How this shows up Symptoms of getting it wrong: a proxy logging "invalid response" after a delete endpoint, intermittent cross-response corruption under keep-alive, a client that hangs waiting for a body that a `Content-Length` promised, or a JSON parser error on a successful DELETE. The fix is always the same — pick the code whose framing matches what you are actually sending, and let the framework, not application code, own the length headers.
- How does a recipient determine where a 204 response ends, given there is no body?It ends at the end of the header section — the blank line. The status code itself tells the parser there is no content, so it does not use Content-Length or Transfer-Encoding to find the end. Any bytes that follow belong to the next message on the connection.
- Is 304 Not Modified allowed to include header fields at all?Yes. A 304 should carry the header fields that would have been sent with a 200 and that matter for cache management — the validators, cache directives, Vary, Date. What it must not send is the representation content itself, since the whole point is that the client already has those bytes.
saying these in an interview costs you the question
- Saying a 204 may include a small JSON body such as {"ok":true}
- Believing Content-Length on a 204 or 304 means bytes will follow
- Treating 205 Reset Content as a synonym for 204
- Claiming a HEAD response carries content when the status is 200
- Assuming HTTP/2 changes the semantics rather than just making the framing safer