mirror of https://github.com/encode/starlette.git
Check if "extensions" in scope before checking the extension (#2438)
This commit is contained in:
parent
8d09cf4b69
commit
e54be85aba
|
@ -337,7 +337,7 @@ class FileResponse(Response):
|
||||||
)
|
)
|
||||||
if scope["method"].upper() == "HEAD":
|
if scope["method"].upper() == "HEAD":
|
||||||
await send({"type": "http.response.body", "body": b"", "more_body": False})
|
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)})
|
await send({"type": "http.response.pathsend", "path": str(self.path)})
|
||||||
else:
|
else:
|
||||||
async with await anyio.open_file(self.path, mode="rb") as file:
|
async with await anyio.open_file(self.path, mode="rb") as file:
|
||||||
|
|
Loading…
Reference in New Issue