Whole file
miguelgrinberg/python-engineio
The author described this change as “Fix error handling for ASGI WebSocket errors (Fixes #210)”. It counts as a record because the check below fails on the code as it stood at e16bbcac1 and passes on e8e4ba5d1, with nothing else changed between the two runs.
Fix saved2021-01-31
Sharing licenceMIT · LICENSE
Change size+1 −1
What the code was meant to do, written into the code itself as a save note
Fix error handling for ASGI WebSocket errors (Fixes #210)
The change
| 190 | 190 | ||
| 191 | 191 | async def make_response(status, headers, payload, environ): | |
| 192 | 192 | headers = [(h[0].encode('utf-8'), h[1].encode('utf-8')) for h in headers] | |
| 193 | - | if 'HTTP_SEC_WEBSOCKET_VERSION' in environ: | |
| 193 | + | if environ['asgi.scope']['type'] == 'websocket': | |
| 194 | 194 | if status.startswith('200 '): | |
| 195 | 195 | await environ['asgi.send']({'type': 'websocket.accept', | |
| 196 | 196 | 'headers': headers}) |
The check that tells the two apart
fail→pass·tests/asyncio/test_async_asgi.py::AsgiTests::test_make_response_websocket_accept
Check file tests/asyncio/test_async_asgi.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.
Origin and history
The code before ite16bbcac1c76dbab61dd378768128af5dfeb8357
Broken version dated2021-01-31
Moduleengineio.async_drivers.asgi
Units changedmake_response
Fingerprintf774823044463ecc
Checked2026-08-18 by goldset/0.1
Every field above is generated by our program. None of it is written by hand.