Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Idea: Pass a copy of the scope to the ASGI app to prevent headers changing to something incompatible #2573

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion uvicorn/protocols/http/h11_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,8 +400,14 @@ def __init__(
# ASGI exception wrapper
async def run_asgi(self, app: ASGI3Application) -> None:
try:
# asgi apps can manipulate the scope, make sure we don't get a manipulated scope
# this can lead to problems when e.g. the headers are exchanged by an iterator
result = await app( # type: ignore[func-returns-value]
self.scope, self.receive, self.send
# asgi apps can manipulate the scope, make sure we don't get a manipulated scope
# this can lead to problems when e.g. the headers are exchanged by an iterator
self.scope.copy(),
self.receive,
self.send,
)
except BaseException as exc:
msg = "Exception in ASGI application\n"
Expand Down
2 changes: 1 addition & 1 deletion uvicorn/protocols/http/httptools_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ def __init__(
async def run_asgi(self, app: ASGI3Application) -> None:
try:
result = await app( # type: ignore[func-returns-value]
self.scope, self.receive, self.send
self.scope.copy(), self.receive, self.send
)
except BaseException as exc:
msg = "Exception in ASGI application\n"
Expand Down
Loading