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

fix asgi spec violation causing crash in lilya #2571

Closed
wants to merge 1 commit into from
Closed
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
5 changes: 4 additions & 1 deletion uvicorn/protocols/http/h11_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,8 +465,11 @@ async def send(self, message: ASGISendEvent) -> None:

status = message["status"]
headers = self.default_headers + list(message.get("headers", []))
# we need to make sure that the headers are a list, the spec requires only an iterator
scope_headers = list(self.scope["headers"])
self.scope["headers"] = scope_headers

if CLOSE_HEADER in self.scope["headers"] and CLOSE_HEADER not in headers:
if CLOSE_HEADER in scope_headers and CLOSE_HEADER not in headers:
headers = headers + [CLOSE_HEADER]

if self.access_log:
Expand Down
5 changes: 4 additions & 1 deletion uvicorn/protocols/http/httptools_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,8 +468,11 @@ async def send(self, message: ASGISendEvent) -> None:

status_code = message["status"]
headers = self.default_headers + list(message.get("headers", []))
# we need to make sure that the headers are a list, the spec requires only an iterator
scope_headers = list(self.scope["headers"])
self.scope["headers"] = scope_headers

if CLOSE_HEADER in self.scope["headers"] and CLOSE_HEADER not in headers:
if CLOSE_HEADER in scope_headers and CLOSE_HEADER not in headers:
headers = headers + [CLOSE_HEADER]

if self.access_log:
Expand Down
Loading