def redirect(self, name, port=80, headers=None):
        url = "http://{0}:{1}".format(name, port)
        if headers:
            response = requests.get(url, headers=headers, allow_redirects=False)
        else:
            response = requests.get(url, allow_redirects=False)

        if response.status_code not in (301, 303):
            return False

        redirect_location = response.headers.get("location", "")
        if not redirect_location.startswith("https://"):
            return False

        if response.status_code != 301:
            logger.error("Server did not redirect with permanent code")
            return False

        return True
Test whether webserver redirects to secure connection.
dataset/ETHPy150Open letsencrypt/letsencrypt/certbot-compatibility-test/certbot_compatibility_test/validator.py/Validator.redirect