Esempio n. 1
0
    async def __call__(self, scope, receive, send):
        if scope["type"] == "lifespan":
            return await self._handle_lifespan(receive, send)

        assert scope["type"] == "http"

        request = Request.incoming(scope["method"], scope["raw_path"],
                                   scope["query_string"], scope["headers"])
        request.scope = scope
        request.content = ASGIContent(receive)

        response = await self.handle(request)
        await send_asgi_response(response, send)

        request.scope = None  # type: ignore
        request.content.dispose()
Esempio n. 2
0
    async def __call__(self, scope, receive, send):
        if scope['type'] == 'lifespan':
            return await self._handle_lifespan(receive, send)

        # assert scope['type'] == 'http'

        request = Request.incoming(scope['method'], scope['raw_path'],
                                   scope['query_string'], scope['headers'])
        request.scope = scope
        request.content = ASGIContent(receive)

        response = await self.handle(request)
        await send_asgi_response(response, send)

        await self.after_response(request, response)

        request.scope = None
        request.content.dispose()