Example #1
0
def build_flask_request(asgi_scope_dict, request_body):
    """Build and return a flask request from ASGI payload

    This function is indented to be used immediately before task invocation
    happen.
    """
    wsgi_environ = build_wsgi_environ(asgi_scope_dict, request_body)
    return flask.Request(wsgi_environ)
Example #2
0
def build_flask_request(asgi_scope_dict, request_body):
    """Build and return a flask request from ASGI payload

    This function is indented to be used immediately before task invocation
    happen.
    """
    wsgi_environ = build_wsgi_environ(asgi_scope_dict, request_body)
    # We set populate_request=False to prevent self reference, which can lead
    # to objects tracked by python garbage collector and memory growth. See
    # https://github.com/ray-project/ray/issues/12395.
    return flask.Request(wsgi_environ, populate_request=False)
Example #3
0
    def __init__(self, *args, **kwargs):
        # Elide the thread-safe request copy and the global bottle.request.
        request = flask.request
        async = kwargs['asynchronous']
        self._handle = request if not async else flask.Request(request.environ)

        # Initialize the request headers.
        self.headers = RequestHeaders(self._handle)

        # Set the method of the request.
        kwargs.update(method=request.method)

        # Continue the initialization.
        super(Request, self).__init__(*args, **kwargs)
Example #4
0
 def __call__(self, environ, start_response):
     req = flask.Request(environ)
     if not self.authDB.isAuthenticated(req):
         response = self.authDB.challenge()
         return response(environ, start_response)
     return self.app(environ, start_response)