MCPcopy
hub / github.com/pallets/werkzeug / on_disconnect

Method on_disconnect

src/werkzeug/wsgi.py:497–517  ·  view source on GitHub ↗

Called when an attempted read receives zero bytes before the limit was reached. This indicates that the client disconnected before sending the full request body. The default behavior is to raise :exc:`.ClientDisconnected`, unless the limit is a maximum and no error w

(self, error: Exception | None = None)

Source from the content-addressed store, hash-verified

495 raise RequestEntityTooLarge()
496
497 def on_disconnect(self, error: Exception | None = None) -> None:
498 """Called when an attempted read receives zero bytes before the limit was
499 reached. This indicates that the client disconnected before sending the full
500 request body.
501
502 The default behavior is to raise :exc:`.ClientDisconnected`, unless the limit is
503 a maximum and no error was raised.
504
505 .. versionchanged:: 2.3
506 Added the ``error`` parameter. Do nothing if the limit is a maximum and no
507 error was raised.
508
509 .. versionchanged:: 2.3
510 Any return value is ignored.
511 """
512 if not self._limit_is_max or error is not None:
513 raise ClientDisconnected()
514
515 # If the limit is a maximum, then we may have read zero bytes because the
516 # streaming body is complete. There's no way to distinguish that from the
517 # client disconnecting early.
518
519 def exhaust(self) -> bytes:
520 """Exhaust the stream by reading until the limit is reached or the client

Callers 1

readintoMethod · 0.95

Calls 1

ClientDisconnectedClass · 0.85

Tested by

no test coverage detected