binding.py 文件源码

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

项目:TA-SyncKVStore 作者: georgestarcher 项目源码 文件源码
def _auth_headers(self):
        """Headers required to authenticate a request.

        Assumes your ``Context`` already has a authentication token or
        cookie, either provided explicitly or obtained by logging
        into the Splunk instance.

        :returns: A list of 2-tuples containing key and value
        """
        if self.has_cookies():
            return [("Cookie", _make_cookie_header(self.get_cookies().items()))]
        elif self.basic and (self.username and self.password):
            token = 'Basic %s' % b64encode("%s:%s" % (self.username, self.password))
            return [("Authorization", token)]
        elif self.token is _NoAuthenticationToken:
            return []
        else:
            # Ensure the token is properly formatted
            if self.token.startswith('Splunk '):
                token = self.token
            else:
                token = 'Splunk %s' % self.token
            return [("Authorization", token)]
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号