python-websockets / websockets

Library for building WebSocket servers and clients in Python
https://websockets.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
5.23k stars 519 forks source link

AssertionError on HTTP responses without a Content-Length #1531

Closed aaugustin closed 1 month ago

aaugustin commented 1 month ago

When a client receives a non-101 response from a server without a Content-Length header, he must read until the end of the stream to get the complete HTTP response.

As a consequence, the Response event is generated after receive_eof and this assertion fails: assert not self.protocol.events_received() (in the asyncio and threading Connection classes).