'The set_language view only redirects to the \'next\' argument if it is
"safe" and its scheme is https if the request was sent over https.'

def test_setlang_http_next(self):

    lang_code = self._get_inactive_language_code()
    non_https_next_url = 'http://testserver/redirection/'
    post_data = {'language': lang_code, 'next': non_https_next_url}
    response = self.client.post('/i18n/setlang/', data=post_data, secure=True)
    self.assertEqual(response.url, '/')
    self.assertEqual(self.client.session[LANGUAGE_SESSION_KEY], lang_code)
    response = self.client.post('/i18n/setlang/', secure=True, HTTP_REFERER=non_https_next_url)
    self.assertEqual(response.url, '/')
    self.assertEqual(self.client.session[LANGUAGE_SESSION_KEY], lang_code)
