mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #23295 -- Removed unnecessary fix_location_header request.get_host() check.
This commit is contained in:
@@ -3,8 +3,8 @@ from __future__ import unicode_literals
|
||||
import io
|
||||
import gzip
|
||||
|
||||
from django.http import HttpRequest, HttpResponse, StreamingHttpResponse
|
||||
from django.http.utils import conditional_content_removal
|
||||
from django.http import HttpRequest, HttpResponse, HttpResponseRedirect, StreamingHttpResponse
|
||||
from django.http.utils import conditional_content_removal, fix_location_header
|
||||
from django.test import TestCase
|
||||
|
||||
|
||||
@@ -69,3 +69,14 @@ class HttpUtilTests(TestCase):
|
||||
res = StreamingHttpResponse(['abc'])
|
||||
conditional_content_removal(req, res)
|
||||
self.assertEqual(b''.join(res), b'')
|
||||
|
||||
def test_fix_location_without_get_host(self):
|
||||
"""
|
||||
Tests that you can return an absolute redirect when the request
|
||||
host is not in ALLOWED_HOSTS. Issue #20472
|
||||
"""
|
||||
request = HttpRequest()
|
||||
def bomb():
|
||||
self.assertTrue(False)
|
||||
request.get_host = bomb
|
||||
fix_location_header(request, HttpResponseRedirect('http://example.com'))
|
||||
|
||||
Reference in New Issue
Block a user