def METHOD_NAME(api_anon, server_ip, protocol, hostname):
    api_anon.headers = {}
    ip_version = 'v6' if ':' in server_ip else 'v4'
    with HostsOverride(hostname, server_ip):
        if not hostname.startswith('checkip.') and not hostname.startswith(f'checkip{ip_version}.'):
            with pytest.raises(exceptions.ConnectionError) as excinfo:
                api_anon.get(f'{protocol}://{hostname}/', allow_redirects=False, verify=False)
            assert 'RemoteDisconnected' in str(excinfo)
            return
        response = api_anon.get(f'{protocol}://{hostname}/', allow_redirects=False)
        if protocol == 'http':
            assert response.headers['Location'] == f'https://{hostname}/'
        else:
            factories = {'v4': ipaddress.IPv4Address, 'v6': ipaddress.IPv6Address}
            assert factories[ip_version](response.text)