mirror of
https://github.com/django/django.git
synced 2025-10-24 22:26:08 +00:00
Fixed #7603 -- Added a 'scheme' property to the HttpRequest object
`HttpRequest.scheme` is `https` if `settings.SECURE_PROXY_SSL_HEADER` is appropriately set and falls back to `HttpRequest._get_scheme()` (a hook for subclasses to implement) otherwise. `WSGIRequest._get_scheme()` makes use of the `wsgi.url_scheme` WSGI environ variable to determine the request scheme. `HttpRequest.is_secure()` simply checks if `HttpRequest.scheme` is `https`. This provides a way to check the current scheme in templates, for example. It also allows us to deal with other schemes. Thanks nslater for the suggestion.
This commit is contained in:
committed by
Tim Graham
parent
9bfe66164e
commit
c7634cd7fe
@@ -32,6 +32,13 @@ Attributes
|
||||
All attributes should be considered read-only, unless stated otherwise below.
|
||||
``session`` is a notable exception.
|
||||
|
||||
.. attribute:: HttpRequest.scheme
|
||||
|
||||
.. versionadded:: 1.7
|
||||
|
||||
A string representing the scheme of the request (``http`` or ``https``
|
||||
usually).
|
||||
|
||||
.. attribute:: HttpRequest.body
|
||||
|
||||
The raw HTTP request body as a byte string. This is useful for processing
|
||||
|
||||
@@ -386,6 +386,12 @@ Templates
|
||||
<naive_vs_aware_datetimes>` ``datetime`` instances performing the expected
|
||||
rendering.
|
||||
|
||||
Requests
|
||||
^^^^^^^^
|
||||
|
||||
* The new :attr:`HttpRequest.scheme <django.http.HttpRequest.scheme>` attribute
|
||||
specifies the scheme of the request (``http`` or ``https`` normally).
|
||||
|
||||
Tests
|
||||
^^^^^
|
||||
|
||||
|
||||
Reference in New Issue
Block a user