def _request(self, endpoint, method, data=None, **kwargs):
        final_url = self.url + endpoint

        if not self._is_authenticated:
            raise LoginRequired

        rq = self.session
        if method == 'get':
            request = rq.get(final_url, **kwargs)
        else:
            request = rq.post(final_url, data, **kwargs)

        request.raise_for_status()
        request.encoding = 'utf_8'

        if len(request.text) == 0:
            data = json.loads('{}')
        else:
            try:
                data = json.loads(request.text)
            except ValueError:
                data = request.text

        return data
From http://www.wordaligned.org/articles/zippy-triples-served-with-python
dataset/ETHPy150Open v1k45/python-qBittorrent/qbittorrent/client.py/Client._request--crossover with--dataset/ETHPy150Open fabiocorneti/django-easytree/easytree/templatetags/easytree_tags.py/previous_current_next