mirror of
https://github.com/django/django.git
synced 2025-08-03 02:23:12 +00:00
Fixed #23960 -- Removed http.fix_location_header
Thanks Carl Meyer for the report and Tim Graham for the review.
This commit is contained in:
parent
0339844b70
commit
a0c2eb46dd
20 changed files with 127 additions and 156 deletions
|
@ -22,6 +22,10 @@ details on these changes.
|
|||
|
||||
* The ``assignment_tag`` helper will be removed.
|
||||
|
||||
* The ``host`` argument to ``assertsRedirects`` will be removed. The
|
||||
compatibility layer which allows absolute URLs to be considered equal to
|
||||
relative ones when the path is identical will also be removed.
|
||||
|
||||
.. _deprecation-removed-in-2.0:
|
||||
|
||||
2.0
|
||||
|
|
|
@ -824,8 +824,10 @@ types of HTTP responses. Like ``HttpResponse``, these subclasses live in
|
|||
|
||||
The first argument to the constructor is required -- the path to redirect
|
||||
to. This can be a fully qualified URL
|
||||
(e.g. ``'http://www.yahoo.com/search/'``) or an absolute path with no
|
||||
domain (e.g. ``'/search/'``). See :class:`HttpResponse` for other optional
|
||||
(e.g. ``'http://www.yahoo.com/search/'``), an absolute path with no domain
|
||||
(e.g. ``'/search/'``), or even a relative path (e.g. ``'search/'``). In that
|
||||
last case, the client browser will reconstruct the full URL itself
|
||||
according to the current path. See :class:`HttpResponse` for other optional
|
||||
constructor arguments. Note that this returns an HTTP status code 302.
|
||||
|
||||
.. attribute:: HttpResponseRedirect.url
|
||||
|
|
|
@ -266,6 +266,21 @@ a directory. Now, Django only silences the exception if the template source
|
|||
does not exist. All other situations result in the original ``IOError`` being
|
||||
raised.
|
||||
|
||||
HTTP redirects no longer forced to absolute URIs
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Relative redirects are no longer converted to absolute URIs. :rfc:`2616`
|
||||
required the ``Location`` header in redirect responses to be an absolute URI,
|
||||
but it has been superseded by :rfc:`7231` which allows relative URIs in
|
||||
``Location``, recognizing the actual practice of user agents, almost all of
|
||||
which support them.
|
||||
|
||||
Consequently, the expected URLs passed to ``assertRedirects`` should generally
|
||||
no longer include the scheme and domain part of the URLs. For example,
|
||||
``self.assertRedirects(response, 'http://testserver/some-url/')`` should be
|
||||
replaced by ``self.assertRedirects(response, '/some-url/')`` (unless the
|
||||
redirection specifically contained an absolute URL, of course).
|
||||
|
||||
Miscellaneous
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
|
|
|
@ -1398,7 +1398,7 @@ your test suite.
|
|||
You can use this as a context manager in the same way as
|
||||
:meth:`~SimpleTestCase.assertTemplateUsed`.
|
||||
|
||||
.. method:: SimpleTestCase.assertRedirects(response, expected_url, status_code=302, target_status_code=200, host=None, msg_prefix='', fetch_redirect_response=True)
|
||||
.. method:: SimpleTestCase.assertRedirects(response, expected_url, status_code=302, target_status_code=200, msg_prefix='', fetch_redirect_response=True)
|
||||
|
||||
Asserts that the response returned a ``status_code`` redirect status,
|
||||
redirected to ``expected_url`` (including any ``GET`` data), and that the
|
||||
|
@ -1408,14 +1408,6 @@ your test suite.
|
|||
``target_status_code`` will be the url and status code for the final
|
||||
point of the redirect chain.
|
||||
|
||||
The ``host`` argument sets a default host if ``expected_url`` doesn't
|
||||
include one (e.g. ``"/bar/"``). If ``expected_url`` is an absolute URL that
|
||||
includes a host (e.g. ``"http://testhost/bar/"``), the ``host`` parameter
|
||||
will be ignored. Note that the test client doesn't support fetching external
|
||||
URLs, but the parameter may be useful if you are testing with a custom HTTP
|
||||
host (for example, initializing the test client with
|
||||
``Client(HTTP_HOST="testhost")``.
|
||||
|
||||
If ``fetch_redirect_response`` is ``False``, the final page won't be
|
||||
loaded. Since the test client can't fetch externals URLs, this is
|
||||
particularly useful if ``expected_url`` isn't part of your Django app.
|
||||
|
@ -1425,6 +1417,11 @@ your test suite.
|
|||
the original request's scheme is used. If present, the scheme in
|
||||
``expected_url`` is the one used to make the comparisons to.
|
||||
|
||||
.. deprecated:: 1.9
|
||||
|
||||
The ``host`` argument is deprecated, as redirections are no longer
|
||||
forced to be absolute URLs.
|
||||
|
||||
.. method:: SimpleTestCase.assertHTMLEqual(html1, html2, msg=None)
|
||||
|
||||
Asserts that the strings ``html1`` and ``html2`` are equal. The comparison
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue