'Keep protocol'

def process_response(self, request, response):

    if getattr(settings, 'HARDTREE_SUBSCRIPTION_SSL_ENABLED', True):
        if (response.status_code == 302):
            redirect_url = request.build_absolute_uri(response['Location'])
            if (request.is_secure() or getattr(settings, 'HARDTREE_SUBSCRIPTION_SSL_ENFORCE', False)):
                response['Location'] = redirect_url.replace('http://', 'https://')
    return response
