Skip to content

Commit

Permalink
Check if "extensions" in scope before checking the extension (#2438)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kludex committed Jan 23, 2024
1 parent 8d09cf4 commit e54be85
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion starlette/responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None:
)
if scope["method"].upper() == "HEAD":
await send({"type": "http.response.body", "body": b"", "more_body": False})
elif "http.response.pathsend" in scope["extensions"]:
elif "extensions" in scope and "http.response.pathsend" in scope["extensions"]:
await send({"type": "http.response.pathsend", "path": str(self.path)})
else:
async with await anyio.open_file(self.path, mode="rb") as file:
Expand Down

0 comments on commit e54be85

Please sign in to comment.