Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/connectrpc/_server_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -554,8 +554,17 @@ def _request_stream(
read_max_bytes: int | None = None,
) -> Iterator[_REQ]:
reader = EnvelopeReader(request_class, codec, compression, read_max_bytes)
for chunk in _read_body(environ):
yield from reader.feed(chunk)
try:
for chunk in _read_body(environ):
yield from reader.feed(chunk)
except ConnectError:
if environ.get("SERVER_PROTOCOL", "").startswith("HTTP/1"):
# In HTTP/1, the request body should be drained before returning. Generally it's
# best for the application server to handle this, but gunicorn is a famous
# server that doesn't do so, so we go ahead and do it ourselves.
for _ in _read_body(environ):
pass
raise


def _response_stream(
Expand Down