Skip to content

Commit

Permalink
Add ASGI pathsend support
Browse files Browse the repository at this point in the history
  • Loading branch information
gi0baro committed Jan 22, 2024
1 parent 2c5b6ca commit 429a80a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion emmett/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,13 @@ async def asgi(self, scope, send):
return
self._headers.update(self._get_stat_headers(stat_data))
await self._send_headers(send)
await self._send_body(send)
if 'http.response.pathsend' in scope['extras']:
await send({
'type': 'http.response.pathsend',
'path': str(self.file_path)
})
else:
await self._send_body(send)
except IOError as e:
if e.errno == errno.EACCES:
await HTTP(403).send(scope, send)
Expand Down

0 comments on commit 429a80a

Please sign in to comment.