fix for invalid ASGI 2.0 event handling #2171
-
Hello, I'm hoping to start a discussion to make the following changes to ASGI event handling in Starlette: Refactor scope assertion to only check the event category (lifecycle, ws, http)RationaleStarlette (incorrectly) asserts lifecycle scope is in lifecycle, ws, or http. This conflicts with the spec directly, where valid lifecycle startup events received by the application include # line 696/697
async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None:
"""
The main entry point to the Router class.
"""
assert "type" in scope
entry = scope["type"].split(".")[0]
assert entry in ("http", "websocket", "lifespan")
if "router" not in scope:
scope["router"] = self
if entry == "lifespan":
await self.lifespan(scope, receive, send)
return Remove un-necessary
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
update: the |
Beta Was this translation helpful? Give feedback.
-
I don't understand what is wrong. |
Beta Was this translation helpful? Give feedback.
-
Actually nevermind, closing this as it was my own misinterpretation of the spec |
Beta Was this translation helpful? Give feedback.
Actually nevermind, closing this as it was my own misinterpretation of the spec