From 9cd2345c8071e53315dd6b8c851cb602709ae6c5 Mon Sep 17 00:00:00 2001 From: Yusur Princeps Date: Sun, 10 Aug 2025 11:08:05 +0200 Subject: [PATCH] ASGI requires the whole body --- src/suou/sass.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/suou/sass.py b/src/suou/sass.py index 5124530..d96621a 100644 --- a/src/suou/sass.py +++ b/src/suou/sass.py @@ -120,6 +120,10 @@ class SassAsyncMiddleware(_MiddlewareFactory): else: break + resp_body = b'' + async for chunk in _read_file(os.path.join(package_dir, result)): + resp_body += chunk + await send({ 'type': 'http.response.start', 'status': 200, @@ -127,11 +131,11 @@ class SassAsyncMiddleware(_MiddlewareFactory): (b'Content-Type', b'text/css; charset=utf-8'), ] }) - async for chunk in _read_file(os.path.join(package_dir, result)): - await send({ - 'type': 'http.response.body', - 'body': chunk - }) + + await send({ + 'type': 'http.response.body', + 'body': resp_body + }) await self.app(scope, receive, send)