sanic-org / sanic

Accelerate your web app development | Build fast. Run fast.

Home Page:https://sanic.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Sanic.handle_request expect request.stream.response exists but AsgiApp.send set it to None

zhu opened this issue · comments

commented

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

Sanic.handle_request expect request.stream.response exists:

response = request.stream.response

sanic/sanic/app.py

Lines 1019 to 1025 in 50117d1

else:
if not hasattr(handler, "is_websocket"):
raise ServerError(
f"Invalid response type {response!r} "
"(need HTTPResponse)"
)

AsgiApp.send set it to None:

sanic/sanic/asgi.py

Lines 223 to 224 in 50117d1

if self.response:
response, self.response = self.response, None
ServerError is always thrown.

Code snippet

No response

Expected Behavior

No exception.

How do you run Sanic?

ASGI

Operating System

Mac

Sanic Version

23.3

Additional context

No response