def dereference_url ( url ) : res = open_url ( url , method = 'HEAD' ) res . close ( ) return res . url
python identify relative redirect http
Makes a HEAD request to find the final destination of a URL after following any redirects
def dereference_url(url):
    """
    Makes a HEAD request to find the final destination of a URL after
    following any redirects
    """
    res = open_url(url, method='HEAD')
    res.close()
    return res.url