Beispiel #1
0
    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})
Beispiel #2
0
    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})
Beispiel #3
0
    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})