http.py 文件源码

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

项目:python-qinlingclient 作者: openstack 项目源码 文件源码
def json_request(self, url, method, **kwargs):
        headers = kwargs.setdefault('headers', {})
        headers['Content-Type'] = kwargs.pop('content_type',
                                             'application/json')

        if 'data' in kwargs:
            kwargs['data'] = jsonutils.dumps(kwargs['data'])
            # NOTE(starodubcevna): We need to prove that json field is empty,
            # or it will be modified by keystone adapter.
            kwargs['json'] = None

        resp = self.request(url, method, **kwargs)
        body = resp.text
        if body:
            try:
                body = jsonutils.loads(body)
            except ValueError:
                pass

        return resp, body
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号