async def finalize_asgi(self, response: Response, send: ASGISend, scope: ASGIScope): if response.exc_info is not None: if self.debug or scope.get('raise_exceptions', False): exc_info = response.exc_info raise exc_info[0].with_traceback(exc_info[1], exc_info[2]) await send({ 'type': 'http.response.start', 'status': response.status_code, 'headers': [[key.encode(), value.encode()] for key, value in response.headers] }) if hasattr(response.content, "read"): body = await self.read(response) while body: await send({ 'type': 'http.response.body', 'body': body, "more_body": True, }) body = await self.read(response) else: body = response.content await send({'type': 'http.response.body', 'body': body})
async def finalize_asgi(self, response: Response, send: ASGISend, scope: ASGIScope): if response.exc_info is not None: if self.debug or scope.get('raise_exceptions', False): exc_info = response.exc_info raise exc_info[0].with_traceback(exc_info[1], exc_info[2]) await send({ 'type': 'http.response.start', 'status': response.status_code, 'headers': [[key.encode(), value.encode()] for key, value in response.headers] }) await send({'type': 'http.response.body', 'body': response.content})
async def finalize_asgi(self, response: Response, send: ASGISend, scope: ASGIScope): if response.exc_info is not None: if self.debug or scope.get("raise_exceptions", False): exc_info = response.exc_info raise exc_info[0].with_traceback(exc_info[1], exc_info[2]) await send({ "type": "http.response.start", "status": response.status_code, "headers": [[key.encode(), value.encode()] for key, value in response.headers], }) await send({"type": "http.response.body", "body": response.content})