From be1ca93a231bc47475daf54279175ed97798ffda Mon Sep 17 00:00:00 2001 From: Adam Hopkins Date: Thu, 5 Nov 2020 09:08:56 +0200 Subject: [PATCH] Resolve mypy issue --- sanic/asgi.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sanic/asgi.py b/sanic/asgi.py index 64cb6d44..75153d48 100644 --- a/sanic/asgi.py +++ b/sanic/asgi.py @@ -355,7 +355,7 @@ class ASGIApp: is_streaming = isinstance(response, StreamingHTTPResponse) if is_streaming and getattr(response, "chunked", False): # disable sanic chunking, this is done at the ASGI-server level - response.chunked = False + setattr(response, "chunked", False) # content-length header is removed to signal to the ASGI-server # to use automatic-chunking if it supports it elif len(content_length) > 0: @@ -364,7 +364,10 @@ class ASGIApp: ] elif not is_streaming: headers += [ - (b"content-length", str(len(response.body)).encode("latin-1")) + ( + b"content-length", + str(len(getattr(response, "body", b""))).encode("latin-1"), + ) ] if "content-type" not in response.headers: