Check if "extensions" in scope before checking the extension (#2438)

This commit is contained in:
Marcelo Trylesinski 2024-01-23 08:42:18 +01:00 committed by GitHub
parent 8d09cf4b69
commit e54be85aba
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 1 additions and 1 deletions

View File

@ -337,7 +337,7 @@ class FileResponse(Response):
)
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: