From a0482c0f1a9e594e6ca1773a93afb64906cc05ea Mon Sep 17 00:00:00 2001 From: Marcelo Trylesinski Date: Tue, 8 Nov 2022 19:43:23 +0100 Subject: [PATCH 1/2] Only stop receiving stream on `body_stream` if body is empty --- starlette/middleware/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/starlette/middleware/base.py b/starlette/middleware/base.py index 586c9870d..8069f0b11 100644 --- a/starlette/middleware/base.py +++ b/starlette/middleware/base.py @@ -89,7 +89,7 @@ async def body_stream() -> typing.AsyncGenerator[bytes, None]: body = message.get("body", b"") if body: yield body - if not message.get("more_body", False): + elif not message.get("more_body", False): break if app_exc is not None: From a71b8518c9b017bbe31e39ee690282e4300538d7 Mon Sep 17 00:00:00 2001 From: Marcelo Trylesinski Date: Tue, 8 Nov 2022 20:28:18 +0100 Subject: [PATCH 2/2] Update starlette/middleware/base.py --- starlette/middleware/base.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/starlette/middleware/base.py b/starlette/middleware/base.py index 8069f0b11..8f2f02ea0 100644 --- a/starlette/middleware/base.py +++ b/starlette/middleware/base.py @@ -89,8 +89,6 @@ async def body_stream() -> typing.AsyncGenerator[bytes, None]: body = message.get("body", b"") if body: yield body - elif not message.get("more_body", False): - break if app_exc is not None: raise app_exc