Actually gets the http. Moved this to it's own private method since
    it is called several times for following redirects

    :param host:
    :param path:
    :param headers:
    :param ssl:
    :return:

def _get_http_request(netloc, path="/", headers=None, ssl=False):
    """
    Actually gets the http. Moved this to it's own private method since
    it is called several times for following redirects

    :param host:
    :param path:
    :param headers:
    :param ssl:
    :return:
    """
    if ssl:
        port = 443
    else:
        port = 80

    host = netloc

    if len(netloc.split(":")) == 2:
        host, port = netloc.split(":")

    request = {"host": host,
               "port": port,
               "path": path,
               "ssl": ssl,
               "method": "GET"}
    if headers:
        request["headers"] = headers

    response = {}

    try:
        conn = ICHTTPConnection(host=host, port=port, timeout=10)

        conn.request(path, headers, ssl, timeout=10)
        response["status"] = conn.status
        response["reason"] = conn.reason
        response["headers"] = conn.headers
        body = conn.body

        try:
            response["body"] = body.encode('utf-8')
        except UnicodeDecodeError:
            # if utf-8 fails to encode, just use base64
            response["body.b64"] = body.encode('base64')

    except Exception as err:
        response["failure"] = str(err)

    result = {"response": response,
              "request": request}

    return result