Skip to content

Don't add Transfer-Encoding to responses that cannot have a body. - #1141

Open
mefyl wants to merge 1 commit into
mirage:mainfrom
mefyl:fix/websocket
Open

Don't add Transfer-Encoding to responses that cannot have a body.#1141
mefyl wants to merge 1 commit into
mirage:mainfrom
mefyl:fix/websocket

Conversation

@mefyl

@mefyl mefyl commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

RFC 7230 §3.3.1 forbids Transfer-Encoding in 1xx, 204, and 304 responses. The previous cohttp 6.x change that defaulted Unknown encoding to Chunked did not account for these response types, causing e.g. WebSocket 101 Switching Protocols responses to include a spurious Transfer-Encoding: chunked header and a trailing chunked body terminator (0\r\n\r\n), breaking the WebSocket handshake for conforming clients.

RFC 7230 §3.3.1 forbids Transfer-Encoding in 1xx, 204, and 304 responses.
The previous cohttp 6.x change that defaulted Unknown encoding to Chunked
did not account for these response types, causing e.g. WebSocket 101
Switching Protocols responses to include a spurious Transfer-Encoding: chunked
header and a trailing chunked body terminator (0\r\n\r\n), breaking the
WebSocket handshake for conforming clients.
@rgrinberg

Copy link
Copy Markdown
Member

I think the tests need to be updated?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants