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

Allow headers to be sent as iterables #1782

Merged
merged 2 commits into from Nov 27, 2022
Merged

Allow headers to be sent as iterables #1782

merged 2 commits into from Nov 27, 2022

Conversation

rijenkii
Copy link
Contributor

Fixes #1781

Copy link
Sponsor Member

@Kludex Kludex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @rijenkii

List[Tuple[bytes, bytes]], message.get("headers", [])
)
headers = self.default_headers + message_headers
headers = self.default_headers + list(message.get("headers", []))
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've modified this to match httptools.

Comment on lines +973 to +976
async def test_iterator_headers(protocol_cls):
async def app(scope, receive, send):
headers = iter([(b"x-test-header", b"test value")])
await send({"type": "http.response.start", "status": 200, "headers": headers})
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've simplified those lines to be more mindful about what we really want to support.

@Kludex Kludex merged commit 95dcf87 into encode:master Nov 27, 2022
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.

Uvicorn assumes that HTTPResponseStartEvent.headers is a List
2 participants