當前位置: 首頁>>代碼示例>>Python>>正文


Python urllib2.parse_keqv_list方法代碼示例

本文整理匯總了Python中urllib2.parse_keqv_list方法的典型用法代碼示例。如果您正苦於以下問題:Python urllib2.parse_keqv_list方法的具體用法?Python urllib2.parse_keqv_list怎麽用?Python urllib2.parse_keqv_list使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在urllib2的用法示例。


在下文中一共展示了urllib2.parse_keqv_list方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: compose

# 需要導入模塊: import urllib2 [as 別名]
# 或者: from urllib2 import parse_keqv_list [as 別名]
def compose(self, digest=None, basic=None, username=None, password=None,
                challenge=None, path=None, method=None):
        assert username and password
        if basic or not challenge:
            assert not digest
            userpass = "%s:%s" % (username.strip(), password.strip())
            return "Basic %s" % userpass.encode('base64').strip()
        assert challenge and not basic
        path = path or "/"
        (_, realm) = challenge.split('realm="')
        (realm, _) = realm.split('"', 1)
        auth = urllib2.AbstractDigestAuthHandler()
        auth.add_password(realm, path, username, password)
        (token, challenge) = challenge.split(' ', 1)
        chal = urllib2.parse_keqv_list(urllib2.parse_http_list(challenge))
        class FakeRequest(object):
            def get_full_url(self):
                return path
            def has_data(self):
                return False
            def get_method(self):
                return method or "GET"
            get_selector = get_full_url
        retval = "Digest %s" % auth.get_authorization(FakeRequest(), chal)
        return (retval,) 
開發者ID:linuxscout,項目名稱:mishkal,代碼行數:27,代碼來源:httpheaders.py

示例2: registry_get

# 需要導入模塊: import urllib2 [as 別名]
# 或者: from urllib2 import parse_keqv_list [as 別名]
def registry_get(self, api):
        url = "https://%s/v2/%s" % (self.registry, api)
        response = get(url, auth=(self.user, self.password),
                       headers={"Accept": 'application/vnd.docker.distribution.manifest.v2+json'},
                       verify=self.verify)
        if response.status_code == 401:
            challenge = response.headers['Www-Authenticate']
            if challenge.startswith("Bearer "):
                challenge = challenge[7:]
            opts = urllib2.parse_keqv_list(urllib2.parse_http_list(challenge))
            authresp = get("{realm}?service={service}&scope={scope}".format(**opts), auth=(self.user, self.password),
                           verify=self.verify)
            if authresp.ok:
                token = authresp.json()['token']
                response = get(url, headers={'Authorization': 'Bearer %s' % token},
                               verify=self.verify)
            else:
                raise TaskError("problem authenticating with docker registry: [%s] %s" % (authresp.status_code,
                                                                                          authresp.content))
        return response 
開發者ID:datawire,項目名稱:forge,代碼行數:22,代碼來源:docker.py

示例3: parse_www_authenticate_header

# 需要導入模塊: import urllib2 [as 別名]
# 或者: from urllib2 import parse_keqv_list [as 別名]
def parse_www_authenticate_header(header):
    """
    Convert a WWW-Authentication header into a dict that can be used
    in a JSON response.
    """
    items = parse_http_list(header)
    return parse_keqv_list(items) 
開發者ID:mozilla,項目名稱:mozilla-django-oidc,代碼行數:9,代碼來源:utils.py

示例4: _parse

# 需要導入模塊: import urllib2 [as 別名]
# 或者: from urllib2 import parse_keqv_list [as 別名]
def _parse(self, authorization):
        try:
            scheme, rest = authorization.split(None, 1)
        except ValueError:
            # Probably "negotiate", which we don't support
            scheme = authorization
            rest = ""
        args = urllib2.parse_keqv_list(urllib2.parse_http_list(rest))
        challengeType = {
            'basic': BasicChallenge,
            'digest': DigestChallenge,
        }.get(scheme.lower())
        if challengeType is None:
            return "", None
        return scheme.lower(), challengeType(**args) 
開發者ID:apple,項目名稱:ccs-calendarserver,代碼行數:17,代碼來源:httpauth.py

示例5: parse_keqv_list

# 需要導入模塊: import urllib2 [as 別名]
# 或者: from urllib2 import parse_keqv_list [as 別名]
def parse_keqv_list(l):
    """A unicode-safe version of urllib2.parse_keqv_list"""
    # With Python 2.6, parse_http_list handles unicode fine
    return urllib2.parse_keqv_list(l) 
開發者ID:kylebebak,項目名稱:Requester,代碼行數:6,代碼來源:utils.py

示例6: parse_authorization_header

# 需要導入模塊: import urllib2 [as 別名]
# 或者: from urllib2 import parse_keqv_list [as 別名]
def parse_authorization_header(authorization_header):
    """Parse an OAuth authorization header into a list of 2-tuples"""
    auth_scheme = 'OAuth '.lower()
    if authorization_header[:len(auth_scheme)].lower().startswith(auth_scheme):
        items = parse_http_list(authorization_header[len(auth_scheme):])
        try:
            return list(parse_keqv_list(items).items())
        except (IndexError, ValueError):
            pass
    raise ValueError('Malformed authorization header') 
開發者ID:kylebebak,項目名稱:Requester,代碼行數:12,代碼來源:utils.py


注:本文中的urllib2.parse_keqv_list方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。