From 7a3fec0dab2f6e72b84cc1464e30c2adceddc2f9 Mon Sep 17 00:00:00 2001 From: Giovanni Barillari Date: Sun, 28 Jan 2024 16:03:47 +0100 Subject: [PATCH] Avoid exceptions in ASGI `HTTPFile` response in case of missing scope extensions --- emmett/http.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/emmett/http.py b/emmett/http.py index da44e28b..c96aa3ea 100644 --- a/emmett/http.py +++ b/emmett/http.py @@ -221,7 +221,7 @@ async def asgi(self, scope, send): return self._headers.update(self._get_stat_headers(stat_data)) await self._send_headers(send) - if 'http.response.pathsend' in scope['extensions']: + if 'http.response.pathsend' in scope.get('extensions', {}): await send({ 'type': 'http.response.pathsend', 'path': str(self.file_path)