From 722a6db8d91604e7ef0952dcd14832f796a1d48b Mon Sep 17 00:00:00 2001 From: Hussein Mohamed <58296855+whos4n3@users.noreply.github.com> Date: Fri, 19 Nov 2021 06:50:02 +0000 Subject: [PATCH] Dispatch http.lifecyle.response from exception handler (#2299) --- sanic/app.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sanic/app.py b/sanic/app.py index c801cd3d..6861bca0 100644 --- a/sanic/app.py +++ b/sanic/app.py @@ -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(