Beispiel #1
0
def test_peek_path_info():
    env = {"SCRIPT_NAME": "/foo", "PATH_INFO": "/aaa/b///c"}

    assert wsgi.peek_path_info(env) == "aaa"
    assert wsgi.peek_path_info(env) == "aaa"
    assert wsgi.peek_path_info(env, charset=None) == b"aaa"
    assert wsgi.peek_path_info(env, charset=None) == b"aaa"
Beispiel #2
0
    def test_peek_path_info(self):
        env = {"SCRIPT_NAME": "/foo", "PATH_INFO": "/aaa/b///c"}

        self.assert_equal(wsgi.peek_path_info(env), "aaa")
        self.assert_equal(wsgi.peek_path_info(env), "aaa")
        self.assert_equal(wsgi.peek_path_info(env, charset=None), b"aaa")
        self.assert_equal(wsgi.peek_path_info(env, charset=None), b"aaa")
Beispiel #3
0
    def test_peek_path_info(self):
        env = {
            'SCRIPT_NAME': '/foo',
            'PATH_INFO': '/aaa/b///c'
        }

        self.assert_equal(wsgi.peek_path_info(env), 'aaa')
        self.assert_equal(wsgi.peek_path_info(env), 'aaa')
        self.assert_equal(wsgi.peek_path_info(env, charset=None), b'aaa')
        self.assert_equal(wsgi.peek_path_info(env, charset=None), b'aaa')
Beispiel #4
0
def test_peek_path_info():
    env = {
        'SCRIPT_NAME': '/foo',
        'PATH_INFO': '/aaa/b///c'
    }

    assert wsgi.peek_path_info(env) == 'aaa'
    assert wsgi.peek_path_info(env) == 'aaa'
    assert wsgi.peek_path_info(env, charset=None) == b'aaa'
    assert wsgi.peek_path_info(env, charset=None) == b'aaa'
 def __call__(self, environ, start_response):
     app = self.get_application(peek_path_info(environ))
     if app is not None:
         pop_path_info(environ)
     else:
         app = self.default_app
     return app(environ, start_response)
 def wsgi_app(self, environ, start_response):
     request = Request(environ)
     adapter = self.url_map.bind_to_environ(request.environ)
     try:
         endpoint, values = adapter.match()
         if endpoint in ['file', 'root_file']:
             return self.serve_file(environ, start_response, endpoint, **values)
         elif endpoint in ['api', 'upload']:
             response = getattr(self, 'on_' + endpoint)(request, **values)
     except HTTPException, e:
         if peek_path_info(environ) == 'ext':
             response = self.on_ext(request)
         else:
             response = e
Beispiel #7
0
 def wsgi_app(self, environ, start_response):
     if self.check_admin():
         request = Request(environ)
         adapter = self.url_map.bind_to_environ(request.environ)
         try:
             endpoint, values = adapter.match()
             if endpoint in ["file", "root_file"]:
                 return self.serve_file(environ, start_response, endpoint, **values)
             elif endpoint in ["api", "upload"]:
                 response = getattr(self, "on_" + endpoint)(request, **values)
         except HTTPException, e:
             if peek_path_info(environ) == "ext":
                 response = self.on_ext(request)
             else:
                 response = e
         return response(environ, start_response)
Beispiel #8
0
    def __call__(self, environ, start_response):
        path_prefix = peek_path_info(environ)
        self._log.debug("Base application __call__ path prefix: '%s'",
                        path_prefix)

        if path_prefix and path_prefix not in self.PREFIX_BLACKLIST:
            app = self.get_application(path_prefix)
            if app is not None:
                pop_path_info(environ)
            else:
                self._log.debug("No IQR application registered for prefix: "
                                "'%s'", path_prefix)
                app = NotFound()
        else:
            self._log.debug("No prefix or prefix in blacklist. "
                            "Using dispatcher app.")
            app = self.wsgi_app

        return app(environ, start_response)
Beispiel #9
0
 def __call__(self, environ, start_response):
     jam.context.environ = environ
     request = JamRequest(environ)
     if self.max_content_length > 0:
         request.max_content_length = 1024 * 1024 * self.max_content_length
     adapter = self.url_map.bind_to_environ(request.environ)
     try:
         endpoint, values = adapter.match()
         if endpoint in ['file', 'root_file']:
             result = self.serve_file(environ, start_response, endpoint, **values)
             return result
         elif endpoint in ['api', 'upload']:
             response = getattr(self, 'on_' + endpoint)(request, **values)
     except HTTPException as e:
         if peek_path_info(environ) == 'ext':
             response = self.on_ext(request)
         else:
             response = e
     jam.context.session = None
     return response(environ, start_response)
Beispiel #10
0
    def __call__(self, environ, start_response):
        host = environ['HTTP_HOST']
        subdomain = self._subdomain(host)
        path = peek_path_info(environ)

        if subdomain in self.subdomains:
            app = self.get_application_by_subdomain(subdomain)
        else:
            app = self.get_application_by_path(path)

        if app is None:
            app = self.default_instances.get(subdomain)
            if app is None:
                app = self.default_app()
                self.setup_login_manager(app)
                self.default_instances[subdomain] = app

        if path in self.strip_paths:
            pop_path_info(environ)

        return app(environ, start_response)
Beispiel #11
0
def healthcheck(app, env):
    if peek_path_info(env) == "healthcheck":
        app.config['SERVER_NAME'] = None
    else:
        app.config['SERVER_NAME'] = config.SERVER_NAME
Beispiel #12
0
def test_peek_path_info():
    """Test path info peeking in wrappers and utils"""
    env = {'SCRIPT_NAME': '/foo', 'PATH_INFO': '/aaa/b///c'}

    assert peek_path_info(env) == 'aaa'
    assert peek_path_info(env) == 'aaa'
Beispiel #13
0
    def test_peek_path_info(self):
        env = {'SCRIPT_NAME': '/foo', 'PATH_INFO': '/aaa/b///c'}

        assert wsgi.peek_path_info(env) == 'aaa'
        assert wsgi.peek_path_info(env) == 'aaa'
Beispiel #14
0
 def __call__(self, environ, start_response):
     if peek_path_info(environ) == 'api':
         return self.backend_app(environ, start_response)
     else:
         return self.frontend_app(environ, start_response)