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 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")
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')
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 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')
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 app(env, start_response): if peek_path_info(env) == "healthcheck": _app.config['SERVER_NAME'] = None else: _app.config['SERVER_NAME'] = config.SERVER_NAME return _app(env, start_response)
def __call__(self, environ, start_response): my_app = self.instances.get(peek_path_info(environ)) if my_app is not None: pop_path_info(environ) else: my_app = self.default_app return my_app(environ, start_response)
def __call__(self, environ, start_response): prefix = wsgi.peek_path_info(environ) if prefix != "local": return self.default_app(environ, start_response) _ = wsgi.pop_path_info(environ) cid = wsgi.pop_path_info(environ) store_app = _local_store_app(cid) return store_app(environ, start_response)
def app(env, start_response): from entropealabs import config from entropealabs.app import App _app = App() if peek_path_info(env) == "healthcheck": _app.config['SERVER_NAME'] = None else: _app.config['SERVER_NAME'] = config.SERVER_NAME return _app(env, start_response)
def attribs(environ, start_response): method = environ[REQUEST_METHOD] if method == 'GET': if peek_path_info(environ): return attrib_values else: return attrib_names else: return Response('Method {} Not Allowed'.format(method), '405 Method Not Allowed')
def get_app(self, environ): prefix = peek_path_info(environ) if prefix == 'health': if not self._health_app: self._health_app = self._make_health_app() return self._health_app elif prefix not in self._app_instances: app = self.create_app(prefix) if not app: return self.default_app self._app_instances[prefix] = app return self._app_instances[prefix]
def data(environ, start_response): method = environ[REQUEST_METHOD] if method == 'GET': if peek_path_info(environ): return get_data else: return search_data elif method == 'POST': return insert_data else: return Response('Method {} Not Allowed'.format(method), '405 Method Not Allowed')
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
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)
def __call__(self, environ, start_response): jam.context.environ = environ request = JamRequest(environ) 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)
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)
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)
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)
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)
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'
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'
def try_(): return peek_path_info(request.environ)
def __call__(self, environ, start_response): app = self.get_application(peek_path_info(environ)) pop_path_info(environ) return app(environ, start_response)
def healthcheck(app, env): if peek_path_info(env) == "healthcheck": app.config['SERVER_NAME'] = None else: app.config['SERVER_NAME'] = config.SERVER_NAME