def get_content_type(response):
    """Get the content-type from a download response header.

    Args:
      response (Python 2: urllib.addinfourl; Python 3: http.client.HTTPResponse): the http response object

    Returns:
      text: the content type from the headers

    """
    try:
        return response.info().get_content_type()
    except AttributeError: # python 2
        t = response.info().type
        return t.decode('UTF-8')