4 Commits

Author SHA1 Message Date
Benoit Chesneau
cf92b2317a Fix duplicate Transfer-Encoding header for BlackSheep streaming
When frameworks like BlackSheep set Transfer-Encoding: chunked on
streaming responses, gunicorn was adding a second header without
checking if one already exists. This caused httpcore to reject the
response with "multiple Transfer-Encoding headers" error.

Fix checks for existing Transfer-Encoding header before adding one,
while still enabling chunked body encoding when the framework sets it.
2026-04-03 21:10:23 +02:00
Benoit Chesneau
3fc9a2f002 Fix WebSocket close handshake to comply with RFC 6455
- Add _close_sent, _close_received, _close_event state variables
- Server now waits for client's close frame response before marking
  connection as closed (5s timeout)
- Update _read_frames loop to continue reading after sending close
- Fix tests to simulate client close frame response
2026-04-03 14:53:36 +02:00
Benoit Chesneau
47bd20a7cb Fix HTTP 100 Continue adding Transfer-Encoding: chunked
Skip adding Transfer-Encoding: chunked for 1xx informational
responses per RFC 9110 Section 15.2.
2026-04-03 13:57:49 +02:00
Benoit Chesneau
136a124674 Add unit tests reproducing ASGI framework compatibility failures
Tests expose HTTP 100 Continue bug: gunicorn incorrectly adds
Transfer-Encoding: chunked to 1xx responses, violating RFC 9110.

Test results:
- 2 FAILED: HTTP 100 Continue (confirms bug)
- 20 PASSED: WebSocket close/binary/handshake

Coverage: websocket.py 62%, protocol.py 29%
2026-04-03 12:11:32 +02:00