def handle_rest_response(self, response, url, method='GET', headers=None, body=None):
    try:
        if self.parseJsonResponse:
            json_response = (json.loads(response) if (len(response) > 1) else None)
            if self.enableLastJsonResponse:
                self.last_json_response = json_response
            return json_response
        else:
            return response
    except ValueError as e:
        ddos_protection = re.search('(cloudflare|incapsula|overload|ddos)', response, flags=re.IGNORECASE)
        exchange_not_available = re.search('(offline|busy|retry|wait|unavailable|maintain|maintenance|maintenancing)', response, flags=re.IGNORECASE)
        if ddos_protection:
            self.raise_error(DDoSProtection, method, url, None, response)
        if exchange_not_available:
            message = (response + ' exchange downtime, exchange closed for maintenance or offline, DDoS protection or rate-limiting in effect')
            self.raise_error(ExchangeNotAvailable, method, url, None, message)
        self.raise_error(ExchangeError, method, url, e, response)
def handle_rest_response(self, response, url, method='GET', headers=None, body=None):
    try:
        if self.parseJsonResponse:
            json_response = (json.loads(response) if (len(response) > 1) else None)
            if self.enableLastJsonResponse:
                self.last_json_response = json_response
            return json_response
        else:
            return response
    except ValueError as e:
        ddos_protection = re.search('(cloudflare|incapsula|overload|ddos)', response, flags=re.IGNORECASE)
        exchange_not_available = re.search('(offline|busy|retry|wait|unavailable|maintain|maintenance|maintenancing)', response, flags=re.IGNORECASE)
        if ddos_protection:
            self.raise_error(DDoSProtection, method, url, None, response)
        if exchange_not_available:
            message = (response + ' exchange downtime, exchange closed for maintenance or offline, DDoS protection or rate-limiting in effect')
            self.raise_error(ExchangeNotAvailable, method, url, None, message)
        self.raise_error(ExchangeError, method, url, e, response)