'The function for retrieving a json result via HTTP.
Args:
url: The URL to retrieve.
retry_count: The number of times to retry in case socket errors,
timeouts, connection resets, etc. are encountered.
rate_limit_timeout: The number of seconds to wait before retrying
when a rate limit notice is returned via rdap+json.
headers: The HTTP headers dictionary. The Accept header defaults
to \'application/rdap+json\'.
Returns:
Dictionary: The data in json format.
Raises:
HTTPLookupError: The HTTP lookup failed.
HTTPRateLimitError: The HTTP request rate limited and retries
were exhausted.'

def get_http_json(self, url=None, retry_count=3, rate_limit_timeout=120, headers=None):

    if (headers is None):
        headers = {'Accept': 'application/rdap+json'}
    try:
        log.debug('HTTP    query    for    {0}    at    {1}'.format(self.address_str, url))
        conn = Request(url, headers=headers)
        data = self.opener.open(conn, timeout=self.timeout)
        try:
            d = json.loads(data.readall().decode('utf-8', 'ignore'))
        except AttributeError:
            d = json.loads(data.read().decode('utf-8', 'ignore'))
        try:
            for tmp in d['notices']:
                if (tmp['title'] == 'Rate    Limit    Notice'):
                    log.debug('RDAP    query    rate    limit    exceeded.')
                    if (retry_count > 0):
                        log.debug('Waiting    {0}    seconds...'.format(str(rate_limit_timeout)))
                        sleep(rate_limit_timeout)
                        return self.get_http_json(url=url, retry_count=(retry_count - 1), rate_limit_timeout=rate_limit_timeout, headers=headers)
                    else:
                        raise HTTPRateLimitError('HTTP    lookup    failed    for    {0}.    Rate    limit    exceeded,    wait    and    try    again    (possibly    a    temporary    block).'.format(url))
        except (KeyError, IndexError):
            pass
        return d
    except (URLError, socket.timeout, socket.error) as e:
        try:
            if (not isinstance(e.reason, (socket.timeout, socket.error))):
                raise HTTPLookupError('HTTP    lookup    failed    for    {0}.'.format(url))
        except AttributeError:
            pass
        log.debug('HTTP    query    socket    error:    {0}'.format(e))
        if (retry_count > 0):
            log.debug('HTTP    query    retrying    (count:    {0})'.format(str(retry_count)))
            return self.get_http_json(url=url, retry_count=(retry_count - 1), rate_limit_timeout=rate_limit_timeout, headers=headers)
        else:
            raise HTTPLookupError('HTTP    lookup    failed    for    {0}.'.format(url))
    except (HTTPLookupError, HTTPRateLimitError) as e:
        raise e
    except:
        raise HTTPLookupError('HTTP    lookup    failed    for    {0}.'.format(url))
