Work around invalid HTTP server behavior for status 204 and 304 responses by tschneidereit · Pull Request #12635 · bytecodealliance/wasmtime

Per spec, an HTTP server isn't allowed to send a body for these status code. Nothing's stopping it from doing so nevertheless, though. This is admittedly very niche and might only actually happen in test suites. It does happen in those, leading to flaky results because whether we report an error here or not depends on whether the body is contained in the same packet as the headers or not.

I think it'd also be okay to instead make these cases always error, though for all I know it's possible that there are niche compatibility concerns with that.

I'm not sure how to add a test to this, because it requires an external server and is flaky, but I put together a repro in a gist. Note that that uses the wasip3 crate, which targets 0.3.0-rc-2026-01-06, so this won't work as-is with Wasmtime's main.