mirror of
https://github.com/django/django.git
synced 2025-08-04 02:48:35 +00:00
Fixed #25211 -- Added HttpRequest.get_port() and USE_X_FORWARDED_PORT setting.
This commit is contained in:
parent
f6259ce776
commit
4dcfbd7923
6 changed files with 67 additions and 1 deletions
|
@ -254,6 +254,14 @@ Methods
|
|||
:class:`~django.middleware.common.CommonMiddleware` or
|
||||
:class:`~django.middleware.csrf.CsrfViewMiddleware`.
|
||||
|
||||
.. method:: HttpRequest.get_port()
|
||||
|
||||
.. versionadded:: 1.9
|
||||
|
||||
Returns the originating port of the request using information from the
|
||||
``HTTP_X_FORWARDED_PORT`` (if :setting:`USE_X_FORWARDED_PORT` is enabled)
|
||||
and ``SERVER_PORT`` ``META`` variables, in that order.
|
||||
|
||||
.. method:: HttpRequest.get_full_path()
|
||||
|
||||
Returns the ``path``, plus an appended query string, if applicable.
|
||||
|
|
|
@ -2621,6 +2621,19 @@ A boolean that specifies whether to use the X-Forwarded-Host header in
|
|||
preference to the Host header. This should only be enabled if a proxy
|
||||
which sets this header is in use.
|
||||
|
||||
.. setting:: USE_X_FORWARDED_PORT
|
||||
|
||||
USE_X_FORWARDED_PORT
|
||||
--------------------
|
||||
|
||||
.. versionadded:: 1.9
|
||||
|
||||
Default: ``False``
|
||||
|
||||
A boolean that specifies whether to use the X-Forwarded-Port header in
|
||||
preference to the ``SERVER_PORT`` ``META`` variable. This should only be
|
||||
enabled if a proxy which sets this header is in use.
|
||||
|
||||
.. setting:: WSGI_APPLICATION
|
||||
|
||||
WSGI_APPLICATION
|
||||
|
@ -3329,6 +3342,7 @@ HTTP
|
|||
* :setting:`SIGNING_BACKEND`
|
||||
* :setting:`USE_ETAGS`
|
||||
* :setting:`USE_X_FORWARDED_HOST`
|
||||
* :setting:`USE_X_FORWARDED_PORT`
|
||||
* :setting:`WSGI_APPLICATION`
|
||||
|
||||
Logging
|
||||
|
|
|
@ -538,6 +538,9 @@ Requests and Responses
|
|||
returning an :class:`~django.http.HttpResponseForbidden` so that
|
||||
:data:`~django.conf.urls.handler403` is invoked.
|
||||
|
||||
* Added :meth:`HttpRequest.get_port() <django.http.HttpRequest.get_port>` to
|
||||
fetch the originating port of the request.
|
||||
|
||||
Tests
|
||||
^^^^^
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue