asgiref
asgiref copied to clipboard
Should frameworks change scope values?
See https://github.com/pgjones/hypercorn/issues/75 where Starlette changes the scope["path"]
, should ASGI frameworks do this or consider the existing values immutable? (I don't think the specification says - I may work around by passing a copy to the framework)
Maybe relevant: https://github.com/encode/starlette/issues/1336.
Yeah, you're not really meant to change the value of path, I feel - since it's meant to always have root_path at the start. I'm not going to go all out and say something absolutely shouldn't, but I think if it's modified then root_path has to be included in that to make things make sense.
We'll fix Starlette. It's not Hypercorn's fault. Uvicorn has the same behavior as Hypercorn. :pray:
Related: Starlette at least mutates scope
even when the spec clearly states "when middleware is modifying the scope, it should make a copy of the scope object before mutating it and passing it to the inner application" 🤷🏻♂️