fasthttp icon indicating copy to clipboard operation
fasthttp copied to clipboard

Parsed 204 response re-serializes with forbidden Transfer-Encoding: chunked

Open davidscottpope-gif opened this issue 2 months ago • 1 comments

On master (7ae14be), parsing a 204 response that carries Transfer-Encoding: chunked and re-serializing it keeps the header:

raw: HTTP/1.1 204 No Content\r\nTransfer-Encoding: chunked\r\n\r\n out: HTTP/1.1 204 No Content\r\nDate: ...\r\nTransfer-Encoding: chunked\r\n\r\n

RFC 9112 section 6.1 forbids Transfer-Encoding on any 1xx or 204 response. #2447 fixed the same problem for Content-Length (via mustSkipContentLengthOnWire), but the Transfer-Encoding path in ResponseHeader.AppendBytes has no equivalent guard. A proxy forwarding a 204 re-emits a framing header announcing a body the status forbids, and strict downstream clients can wait for chunks that never come.

Happy to send a PR extending the #2447 guard to Transfer-Encoding, with a regression test.

AI disclosure: I used AI tools to find and reproduce this; I reviewed it myself.

davidscottpope-gif avatar Oct 03 '26 19:10 davidscottpope-gif

Confirmed on current master. A PR would be welcome.

erikdubbelboer avatar Oct 04 '26 04:10 erikdubbelboer