def requestUrl(url, content_type="text/plain", headers=None, method="GET", port=None, body="", user=None, password=None):
    
    Console.info("Opening %s request to %s..." % (method, url))

    parsed = urllib.parse.urlparse(url)
    
    if parsed.scheme== "http":
        request = http.client.HTTPConnection(parsed.netloc)
    elif parsed.scheme== "https":
        request = http.client.HTTPSConnection(parsed.netloc)
    else:
        raise Exception("Unsupported url: %s" % url)
    
    if parsed.query:
        request.putrequest(method, parsed.path + "?" + parsed.query)
    else:
        request.putrequest(method, parsed.path)
    
    request.putheader("Content-Type", content_type)
    request.putheader("Content-Length", str(len(body)))

    if user is not None and password is not None:
        auth = "Basic %s" % base64.b64encode(("%s:%s" % (user, password)).encode("utf-8")).decode("utf-8")
        request.putheader("Authorization", auth)
        
    request.endheaders()
    
    if body:
        Console.info("Sending data (%s bytes)..." % len(body))
    else:
        Console.info("Sending request...")

    Console.indent()

    request.send(body)

    response = request.getresponse()
    
    res_code = int(response.getcode())
    res_headers = dict(response.getheaders())
    res_content = response.read()
    res_success = False
    
    if res_code >= 200 and res_code <= 300:
        Console.debug("HTTP Success!")
        res_success = True
    else:
        Console.error("HTTP Failure Code: %s!", res_code)
        
    if "Content-Type" in res_headers:
        res_type = res_headers["Content-Type"]
        
        if ";" in res_type:
            res_type = res_type.split(";")[0]
            
        if res_type in ("application/json", "text/html", "text/plain"):
            res_content = res_content.decode("utf-8")

        if res_type == "application/json":
            res_content = json.loads(res_content)
            
            if "error" in res_content:
                Console.error("Error %s: %s", res_content["error"], res_content["reason"])
            elif "reason" in res_content:
                Console.info("Success: %s" % res_content["reason"])
                
    Console.outdent()
    
    return res_success, res_headers, res_content




#
# Multipart Support
#
Test application of extra filters
dataset/ETHPy150Open zynga/jasy/jasy/http/Request.py/requestUrl--crossover with--dataset/ETHPy150Open sahana/eden/modules/unit_tests/s3/s3resource.py/ResourceSelectTests.testApplyExtraFilter