Return the full url that this proxy request will be routed to
        The 'environ' PATH_INFO and REQUEST_URI will be modified based on the returned url

        Default is to use the 'proxy_prefix' to point to the proxy collection
346715
def proxy_route_request(self, url, environ):
        
        if self.proxy_default_timestamp:
            environ['pywb_proxy_default_timestamp'] = self.proxy_default_timestamp

        return self.proxy_prefix + url
1277066
def _routes(self, app):
        
        _routes = []
        prefix = self.url_prefix if self.url_prefix is not None else ""
        for rule in app.url_map.iter_rules():
            if str(rule).startswith(prefix):
                _routes.append({
                    'path':rule.rule,
                    'name':rule.endpoint,
                    'methods':list(rule.methods)
                })
        returns = {
            'api': self.name,
            'url_root': request.url_root,
            'routes': _routes
        }
        return jsonify(returns)
523797
def _make_full_url(self, url):
        

        return SLASH.join([self._api_base_url, url.lstrip(SLASH)])
180837
def build_url(self):
        
        url = "%s/1.0/%s/%s/%s" % (
            self.request.endpoint.get_url(),
            self.request.api_object,
            self.request.api_method,
            to_hex(self.request.nonce)
        )
        return url
1220392
def get_url(self, environ):
        """"""
        if self.override_url:
            url = self.override_url
        else:
            # PEP333: wsgi.url_scheme, HTTP_HOST, SERVER_NAME, and SERVER_PORT
            # can be used to reconstruct a request's complete URL

            # Much of the following is copied from bottle.py
            http = (environ.get('HTTP_X_FORWARDED_PROTO') or
                    environ.get('wsgi.url_scheme', 'http'))
            host = (environ.get('HTTP_X_FORWARDED_HOST') or
                    environ.get('HTTP_HOST'))
            if not host:
                # HTTP 1.1 requires a Host-header. This is for HTTP/1.0
                # clients.
                host = environ.get('SERVER_NAME', '127.0.0.1')
                port = environ.get('SERVER_PORT')
                if port and port != ('80' if http == 'http' else '443'):
                    host += ':' + port
            url = "%s://%s" % (http, host)
        return url
311103
def request_uri(self):
        
        result = '/{0}'.format(self.path.lstrip('/'))
        if self.query is not None and self.query != '' and self.query != {}:
            result += '?{0}'.format(self.encoded_query())
        if self.fragment is not None and self.fragment != '':
            result += '#{0}'.format(self.fragment)
        return result
858624
def _get_request(url_root,api_key,path,response_type,params, ssl_verify):
    
    url = _url_builder(url_root,api_key,path,params)
    content = _fetch(url, ssl_verify)
    response = _dispatch(response_type)(content)
    return response
309033
def urlopen(self, method, url, redirect=True, **kw):
        ""
        u = parse_url(url)

        if u.scheme == "http":
            # For proxied HTTPS requests, httplib sets the necessary headers
            # on the CONNECT to the proxy. For HTTP, we'll definitely
            # need to set 'Host' at the very least.
            headers = kw.get('headers', self.headers)
            kw['headers'] = self._set_proxy_headers(url, headers)

        return super(ProxyManager, self).urlopen(method, url, redirect=redirect, **kw)
1156572
def access_route(self):
        
        if "HTTP_X_FORWARDED_FOR" in self.environ:
            addr = self.environ["HTTP_X_FORWARDED_FOR"].split(",")
            return self.list_storage_class([x.strip() for x in addr])
        elif "REMOTE_ADDR" in self.environ:
            return self.list_storage_class([self.environ["REMOTE_ADDR"]])
        return self.list_storage_class()
785480
def url(self):
        """"""
        if self._url is None:
            self._url = request_uri(self.environ, include_query=1)
        return self._url
278949
def resource_uri(self):
        
        primary_key_value = getattr(self, self.primary_key(), None)
        return '/{}/{}'.format(self.endpoint(), primary_key_value)
591074
def get(self, request):
        
        # No virtual hosts specified; default behavior
        if not self.hosts:
            return self._get(request.path, request.method, "")
        # virtual hosts specified; try to match route to the host header
        try:
            return self._get(
                request.path, request.method, request.headers.get("Host", "")
            )
        # try default hosts
        except NotFound:
            return self._get(request.path, request.method, "")
762034
def get_base_url(self):
        
        return "http://{hostname}:{port}/{api}".format(
                hostname=self.hostname,
                port=self.port,
                api=self.api_version)
466135
def flattened_params_url(self, path_prefix, *paths, **kparams):
        

        base = self.base_url + path_prefix
        for p in paths:
            base += "/"
            base += p
        if kparams:
            base += "?"
            # use %r in val?
            base += '&'.join("%s=%s" % (key,val) for (key,val) in kparams.items())
        return base
1320196
def resolve_request_path(requested_uri):
    
    from settings import PATH_ALIASES

    for key, val in PATH_ALIASES.items():
        if re.match(key, requested_uri):
            return re.sub(key, val, requested_uri)
    return requested_uri
752119
def get_environ_proxies():
    """"""

    proxy_keys = [
        'all',
        'http',
        'https',
        'ftp',
        'socks',
        'ws',
        'wss',
        'no'
    ]

    def get_proxy(k):
        return os.environ.get(k) or os.environ.get(k.upper())

    proxies = [(key, get_proxy(key + '_proxy')) for key in proxy_keys]
    return dict([(key, val) for (key, val) in proxies if val])
74056
def _uri(self, url):
        """"""
        if url and not url.startswith('/'):
            # Then this must be a proxy request.
            return url
        uri = "{0}://{1}{2}{3}".format(
            self._protocol,
            self.real_connection.host,
            self._port_postfix(),
            url,
        )
        return uri