Repository navigation
fix(server): omit content for 205 responses - #4262
Open
akasakariko wants to merge 1 commit into
Open
akasakariko wants to merge 1 commit into
akasakariko wants to merge 1 commit into
Conversation
A 205 response must not contain content (RFC 9110 Section 15.3.6). The HTTP/1 server now drops the body and sends `Content-Length: 0` so the response stays correctly framed. The HTTP/2 server drops the body and removes `Content-Length`. The HTTP/2 server also stops sending body data for responses to HEAD requests and removes `Content-Length` from 204 responses, as required by RFC 9110 Section 6.4.1 and RFC 9113 Section 8.1. Closes hyperium#4261
agammann
reviewed
Nov 10, 2026
agammann
left a comment
There was a problem hiding this comment.
The HTTP/2 branch handles HEAD before the 204/205 status case. For a HEAD request whose service returns 204 No Content with a body that has an exact size hint, is_head sets a nonzero Content-Length and the else if that removes that header is skipped. The new GET 204 test and HEAD 200 test do not cover their intersection. Could the status restriction take precedence for 204/205, with a HEAD 204 (and ideally 205) regression? I reviewed the diff and surrounding framing code; I did not run tests locally.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A 205 response must not contain content (RFC 9110 Section 15.3.6), but the server still sent a body and a non-zero
Content-LengthContent-Length: 0, keeping the response correctly framedContent-Lengthfor 205 responsesContent-Lengthfor 204 responses (RFC 9113 Section 8.1)The HTTP/1 behavior matches the existing handling for empty 205 responses, which already sent
Content-Length: 0Tests were added in
tests/server.rsfor HTTP/1 205 responses and HTTP/2 204, 205, and HEAD responsesVerification:
cargo test --features full: 332 passed, 10 ignoredcargo clippy --features full -- -D warnings: exits 0 (3 pre-existing unknown lint warnings)rustfmt --check --edition 2021 $(git ls-files '*.rs'): passescargo check --no-default-features --features client,http1/client,http2/server,http1/server,http2/client,http1,http2/server,http1,http2with-D dead_code -D unused_imports: passesThe description, docs, and comments (words meant for humans) are written by a human, not by an LLM.