expression
204 responses and body policy
A 204 response has no content. HEAD and 304 also have distinct content restrictions. The http crate models messages but is not a complete semantic validator; obey protocol rules when using a transport. External crate example; constructs data in memory, does not send requests. Expected stdout (not executed): 204 true Common mistake: Trying to decode a JSON response body unconditionally after a successful status.
Formal Syntax & Structure
rust syntaxrust
Response::builder().status(StatusCode::NO_CONTENT).body(())Working Example
Example Snippetrust
fn main() { use http::{Response, StatusCode}; let r = Response::builder().status(StatusCode::NO_CONTENT).body(()).unwrap(); println!("{} {}", r.status().as_u16(), r.status().is_success());}