Dispatch http.lifecyle.response from exception handler (#2299)

This commit is contained in:
Hussein Mohamed 2021-11-19 06:50:02 +00:00 committed by GitHub
parent 9c576c74db
commit 722a6db8d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -775,6 +775,14 @@ class Sanic(BaseSanic, metaclass=TouchUpMeta):
if request.stream:
response = request.stream.response
if isinstance(response, BaseHTTPResponse):
await self.dispatch(
"http.lifecycle.response",
inline=True,
context={
"request": request,
"response": response,
},
)
await response.send(end_stream=True)
else:
raise ServerError(