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


Python request.parse_keqv_list方法代碼示例

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


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

示例1: parse_www_authenticate_header

# 需要導入模塊: from urllib import request [as 別名]
# 或者: from urllib.request 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

示例2: parse_keqv_list

# 需要導入模塊: from urllib import request [as 別名]
# 或者: from urllib.request 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

示例3: parse_authorization_header

# 需要導入模塊: from urllib import request [as 別名]
# 或者: from urllib.request 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

示例4: __init__

# 需要導入模塊: from urllib import request [as 別名]
# 或者: from urllib.request import parse_keqv_list [as 別名]
def __init__(
        self, auth_header, http_method,
        debug=False, accept_charset=DEFAULT_CHARSET[:],
    ):
        self.http_method = http_method
        self.debug = debug

        if not self.matches(auth_header):
            raise ValueError('Authorization scheme is not "Digest"')

        self.auth_header = _try_decode_header(auth_header, accept_charset)

        scheme, params = self.auth_header.split(' ', 1)

        # make a dict of the params
        items = parse_http_list(params)
        paramsd = parse_keqv_list(items)

        self.realm = paramsd.get('realm')
        self.username = paramsd.get('username')
        self.nonce = paramsd.get('nonce')
        self.uri = paramsd.get('uri')
        self.method = paramsd.get('method')
        self.response = paramsd.get('response')  # the response digest
        self.algorithm = paramsd.get('algorithm', 'MD5').upper()
        self.cnonce = paramsd.get('cnonce')
        self.opaque = paramsd.get('opaque')
        self.qop = paramsd.get('qop')  # qop
        self.nc = paramsd.get('nc')  # nonce count

        # perform some correctness checks
        if self.algorithm not in valid_algorithms:
            raise ValueError(
                self.errmsg("Unsupported value for algorithm: '%s'" %
                            self.algorithm))

        has_reqd = (
            self.username and
            self.realm and
            self.nonce and
            self.uri and
            self.response
        )
        if not has_reqd:
            raise ValueError(
                self.errmsg('Not all required parameters are present.'))

        if self.qop:
            if self.qop not in valid_qops:
                raise ValueError(
                    self.errmsg("Unsupported value for qop: '%s'" % self.qop))
            if not (self.cnonce and self.nc):
                raise ValueError(
                    self.errmsg('If qop is sent then '
                                'cnonce and nc MUST be present'))
        else:
            if self.cnonce or self.nc:
                raise ValueError(
                    self.errmsg('If qop is not sent, '
                                'neither cnonce nor nc can be present')) 
開發者ID:cherrypy,項目名稱:cherrypy,代碼行數:62,代碼來源:auth_digest.py


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