From c7634cd7fe7dc09338fcec0ca48d816a29d791b0 Mon Sep 17 00:00:00 2001 From: Unai Zalakain Date: Tue, 8 Oct 2013 20:30:29 +0200 Subject: 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. --- docs/ref/request-response.txt | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'docs/ref') diff --git a/docs/ref/request-response.txt b/docs/ref/request-response.txt index a4ed6a2645..57222c8ca7 100644 --- a/docs/ref/request-response.txt +++ b/docs/ref/request-response.txt @@ -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 -- cgit v1.3