request.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:httpolice 作者: vfaronov 项目源码 文件源码
def _check_basic_auth(req, hdr, credentials):
    if isinstance(credentials, six.text_type):   # ``token68`` form
        try:
            credentials = base64.b64decode(credentials)
        except Exception as e:
            req.complain(1210, header=hdr, error=e)
        else:
            # RFC 7617 section 2 requires that,
            # whatever the encoding of the credentials,
            # it must be ASCII-compatible, so we don't need to know it.
            if b':' not in credentials:
                req.complain(1211, header=hdr)
            for c in six.iterbytes(credentials):
                if CTL.match(six.int2byte(c)):
                    req.complain(1212, header=hdr, char=hex(c))
    else:
        req.complain(1209, header=hdr)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号