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

Conversation

devkral
Copy link

@devkral devkral commented Feb 5, 2025

Summary

Checklist

  • I understand that this PR may be closed in case there was no previous discussion. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.

Changes:

The asgi spec allows changing the scope. We rely on headers as list so we copy the scope to the asgi app. Otherwise we can have suddenly headers which are an (exhausted) iterator.

Discussion: #2572 .

I am not sure if this is a good solution. In lilya we copy the scope because of this issue. So please give me guidance in case it
doesn't matches your expectations.
I can only say: I investigated a sudden crash in lilya and could trace it back to my changes and the expectation that the headers are something like a list in uvicorn. No offense meant, it is just an idea how to fix the root issue.

Changes:

The asgi spec allows changing the scope. We rely on headers as list
so we copy the scope to the asgi app. Otherwise we can have suddenly
headers which are an (exhausted) iterator.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant