This repository was archived by the owner on Oct 8, 2025. It is now read-only.
Commit 8deb39c
committed
fix: Handle client disconnection for HTTP and WebSocket according to ASGI spec
For HTTP connections:
- If the app is sending data using the send callable, according to the ASGI spec, it should throw an exception
in case of client disconnection. Previously, even if we processed the client_error message
and set the http->closed state, it wouldn't throw an error because it wasn't handled.
This change ensures that the exception is raised as per the ASGI spec.
For WebSocket connections:
- If the app is awaiting on receive, it would get a 'websocket.disconnect' event.
However, if the app continues to send data using the send callable after receiving this event,
it wouldn't raise an error because ws->state = NXT_WS_DISCONNECTED was never set in that case.
According to the ASGI spec, if send is called after receiving a 'websocket.disconnect' event or on a closed client,
it should raise an exception. This change ensures that the exception is raised as per the ASGI spec.1 parent 87431eb commit 8deb39c
File tree
2 files changed
+13
-8
lines changed- src/python
2 files changed
+13
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
368 | 368 | | |
369 | 369 | | |
370 | 370 | | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
371 | 376 | | |
372 | 377 | | |
373 | 378 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
273 | 273 | | |
274 | 274 | | |
275 | 275 | | |
276 | | - | |
| 276 | + | |
277 | 277 | | |
278 | 278 | | |
279 | | - | |
| 279 | + | |
280 | 280 | | |
281 | 281 | | |
282 | 282 | | |
| |||
368 | 368 | | |
369 | 369 | | |
370 | 370 | | |
371 | | - | |
| 371 | + | |
372 | 372 | | |
373 | 373 | | |
374 | 374 | | |
375 | | - | |
| 375 | + | |
376 | 376 | | |
377 | 377 | | |
378 | 378 | | |
| |||
433 | 433 | | |
434 | 434 | | |
435 | 435 | | |
436 | | - | |
| 436 | + | |
437 | 437 | | |
438 | 438 | | |
439 | 439 | | |
440 | | - | |
| 440 | + | |
441 | 441 | | |
442 | 442 | | |
443 | 443 | | |
| |||
984 | 984 | | |
985 | 985 | | |
986 | 986 | | |
987 | | - | |
988 | | - | |
| 987 | + | |
989 | 988 | | |
| 989 | + | |
990 | 990 | | |
991 | 991 | | |
992 | 992 | | |
| |||
0 commit comments