def request(self, method, url, data=None, headers=None):
        if data and isinstance(data, bytes):
            data = data.decode()

        if data and not isinstance(data, basestring):
            data = urlencode(data)

        if data is not None:
            data = data.encode('utf8')

        # If we have data and Content-Type is not set, set it...
        if data and not headers.get('Content-Type', None):
            headers['Content-Type'] = 'application/x-www-form-urlencoded'

        request_headers = self.headers.copy()

        if headers:
            for k, v in headers.items():
                if v is None:
                    del request_headers[k]
                else:
                    request_headers[k] = v

        try:
            func = getattr(requests, method.lower())
        except AttributeError:
            raise Exception("HTTP method '{}' is not supported".format(method))
        response = func(url, data=data, headers=request_headers)

        if response.status_code > 399:
            raise HTTPError(response.status_code, "{}: {}".format(
                response.status_code, response.content))
        return response
dataset/ETHPy150Open burnash/gspread/gspread/httpsession.py/HTTPSession.request/original