Skip to content

Commit e54be85

Browse files
authored
Check if "extensions" in scope before checking the extension (#2438)
1 parent 8d09cf4 commit e54be85

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

starlette/responses.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None:
337337
)
338338
if scope["method"].upper() == "HEAD":
339339
await send({"type": "http.response.body", "body": b"", "more_body": False})
340-
elif "http.response.pathsend" in scope["extensions"]:
340+
elif "extensions" in scope and "http.response.pathsend" in scope["extensions"]:
341341
await send({"type": "http.response.pathsend", "path": str(self.path)})
342342
else:
343343
async with await anyio.open_file(self.path, mode="rb") as file:

0 commit comments

Comments
 (0)