def getQualifiedURL(uri = None):
    """ Return a full URL starting with schema, servername and port.

        *uri* -- append this server-rooted uri (must start with a slash)
    """
    schema, stdport = (('http', '80'), ('https', '443'))[isSSL()]
    host = getEnvValue('HTTP_HOST')
    if not host:
        host = getEnvValue('SERVER_NAME')
        port = getEnvValue('SERVER_PORT', '80')
        if port != stdport: host = host + ":" + port

    result = "%s://%s" % (schema, host)
    if uri: result = result + uri
    
    return result
 Return a full URL starting with schema, servername and port.

        *uri* -- append this server-rooted uri (must start with a slash)
    
recipes/Python/52287_Handling_URLs_withCGI/recipe-52287.py