mirror of
https://github.com/django/django.git
synced 2025-10-24 14:16:09 +00:00
Refs #26428 -- Added support for relative path redirects to the test client.
Thanks iktyrrell for the patch.
This commit is contained in:
@@ -26,7 +26,7 @@ from django.utils.encoding import force_bytes, force_str, uri_to_iri
|
||||
from django.utils.functional import SimpleLazyObject, curry
|
||||
from django.utils.http import urlencode
|
||||
from django.utils.itercompat import is_iterable
|
||||
from django.utils.six.moves.urllib.parse import urlparse, urlsplit
|
||||
from django.utils.six.moves.urllib.parse import urljoin, urlparse, urlsplit
|
||||
|
||||
__all__ = ('Client', 'RedirectCycleError', 'RequestFactory', 'encode_file', 'encode_multipart')
|
||||
|
||||
@@ -699,7 +699,12 @@ class Client(RequestFactory):
|
||||
if url.port:
|
||||
extra['SERVER_PORT'] = str(url.port)
|
||||
|
||||
response = self.get(url.path, QueryDict(url.query), follow=False, **extra)
|
||||
# Prepend the request path to handle relative path redirects
|
||||
path = url.path
|
||||
if not path.startswith('/'):
|
||||
path = urljoin(response.request['PATH_INFO'], path)
|
||||
|
||||
response = self.get(path, QueryDict(url.query), follow=False, **extra)
|
||||
response.redirect_chain = redirect_chain
|
||||
|
||||
if redirect_chain[-1] in redirect_chain[:-1]:
|
||||
|
||||
Reference in New Issue
Block a user