Re: [Django] #7603: The Request object should have a "scheme" attribute

18 views
Skip to first unread message

Django

unread,
Sep 11, 2011, 5:27:20 PM9/11/11
to django-...@googlegroups.com
#7603: The Request object should have a "scheme" attribute
---------------------------------------+-------------------------------
Reporter: nslater | Owner: nslater
Type: New feature | Status: assigned
Milestone: | Component: HTTP handling
Version: SVN | Severity: Normal
Resolution: | Keywords:
Triage Stage: Accepted | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
---------------------------------------+-------------------------------
Changes (by Alex):

* ui_ux: => 0
* easy: => 0
* stage: Design decision needed => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/7603#comment:9>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Oct 8, 2013, 2:39:53 PM10/8/13
to django-...@googlegroups.com
#7603: The Request object should have a "scheme" attribute
-------------------------------+------------------------------------

Reporter: nslater | Owner: nslater
Type: New feature | Status: assigned
Component: HTTP handling | Version: master

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------
Changes (by unaizalakain):

* has_patch: 0 => 1


Comment:

Patch: https://github.com/unaizalakain/django/tree/ticket_7603

HttpRequest.get_scheme() uses self.is_secure() to determine if scheme is
'http' or 'https' wether WSGIRequest.get_scheme() makes use of the
'wsgi.url_scheme' WSGI environ variable.

This provides a handful method to check for current scheme in, for
example, templates. It also allows to deal with other schemes.

--
Ticket URL: <https://code.djangoproject.com/ticket/7603#comment:10>

Django

unread,
Oct 11, 2013, 2:30:37 PM10/11/13
to django-...@googlegroups.com
#7603: Add HttpRequest.get_scheme()

-------------------------------+------------------------------------
Reporter: nslater | Owner: nslater
Type: New feature | Status: assigned
Component: HTTP handling | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------
Changes (by timo):

* needs_better_patch: 0 => 1


Comment:

Comments for improvement on the branch.

--
Ticket URL: <https://code.djangoproject.com/ticket/7603#comment:11>

Django

unread,
Oct 13, 2013, 5:14:16 AM10/13/13
to django-...@googlegroups.com
#7603: Add HttpRequest.get_scheme()
-------------------------------+------------------------------------
Reporter: nslater | Owner: nslater
Type: New feature | Status: assigned
Component: HTTP handling | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------

Comment (by unaizalakain):

Comments taken into account, pull request:
https://github.com/django/django/pull/1730

--
Ticket URL: <https://code.djangoproject.com/ticket/7603#comment:12>

Django

unread,
Oct 13, 2013, 7:16:14 AM10/13/13
to django-...@googlegroups.com
#7603: Add HttpRequest.scheme property

-------------------------------+------------------------------------
Reporter: nslater | Owner: nslater
Type: New feature | Status: assigned
Component: HTTP handling | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------

--
Ticket URL: <https://code.djangoproject.com/ticket/7603#comment:13>

Django

unread,
Oct 14, 2013, 6:35:36 PM10/14/13
to django-...@googlegroups.com
#7603: Add HttpRequest.scheme property
-------------------------------+----------------------------------------
Reporter: nslater | Owner: unaizalakain

Type: New feature | Status: assigned
Component: HTTP handling | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------+----------------------------------------
Changes (by unaizalakain):

* owner: nslater => unaizalakain


--
Ticket URL: <https://code.djangoproject.com/ticket/7603#comment:14>

Django

unread,
Oct 14, 2013, 7:13:07 PM10/14/13
to django-...@googlegroups.com
#7603: Add HttpRequest.scheme property
-------------------------------------+-------------------------------------
Reporter: nslater | Owner:
Type: New feature | unaizalakain
Component: HTTP handling | Status: assigned
Severity: Normal | Version: master
Keywords: | Resolution:
Has patch: 1 | Triage Stage: Ready for
Needs tests: 0 | checkin
Easy pickings: 0 | Needs documentation: 0
| Patch needs improvement: 0
| UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timo):

* needs_better_patch: 1 => 0
* stage: Accepted => Ready for checkin


Comment:

This looks good to me, but since it's potentially security related I'd
like one more +1 before committing.

--
Ticket URL: <https://code.djangoproject.com/ticket/7603#comment:15>

Django

unread,
Oct 15, 2013, 2:51:12 AM10/15/13
to django-...@googlegroups.com
#7603: Add HttpRequest.scheme property
-------------------------------------+-------------------------------------
Reporter: nslater | Owner:
Type: New feature | unaizalakain
Component: HTTP handling | Status: assigned
Severity: Normal | Version: master
Keywords: | Resolution:
Has patch: 1 | Triage Stage: Ready for
Needs tests: 0 | checkin
Easy pickings: 0 | Needs documentation: 0
| Patch needs improvement: 0
| UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by aaugustin):

LGTM.

Why do the docs say "normally" and "usually"? The current implementation
is always going to return 'http' or 'https'. Let's avoid vague terms.

--
Ticket URL: <https://code.djangoproject.com/ticket/7603#comment:16>

Django

unread,
Oct 15, 2013, 4:06:36 AM10/15/13
to django-...@googlegroups.com
#7603: Add HttpRequest.scheme property
-------------------------------------+-------------------------------------
Reporter: nslater | Owner:
Type: New feature | unaizalakain
Component: HTTP handling | Status: assigned
Severity: Normal | Version: master
Keywords: | Resolution:
Has patch: 1 | Triage Stage: Ready for
Needs tests: 0 | checkin
Easy pickings: 0 | Needs documentation: 0
| Patch needs improvement: 0
| UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by unaizalakain):

In fact, scheme is gotten from `wsgi.url_scheme` WSGI variable.
[[http://wsgi.readthedocs.org/en/latest/definitions.html?highlight=url_scheme
#envvar-wsgi.url_scheme|The docs]] state that:

`wsgi.url_scheme`: A string representing the "scheme" portion of the
URL at which the application is being invoked. Normally, this will have
the value "http" or "https", as appropriate.

It's true that this will always be `http` or `https` but there's no
guarantee about it.

--
Ticket URL: <https://code.djangoproject.com/ticket/7603#comment:17>

Django

unread,
Oct 15, 2013, 9:07:12 AM10/15/13
to django-...@googlegroups.com
#7603: Add HttpRequest.scheme property
-------------------------------------+-------------------------------------
Reporter: nslater | Owner:
Type: New feature | unaizalakain
Component: HTTP handling | Status: closed
Severity: Normal | Version: master
Keywords: | Resolution: fixed

Has patch: 1 | Triage Stage: Ready for
Needs tests: 0 | checkin
Easy pickings: 0 | Needs documentation: 0
| Patch needs improvement: 0
| UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"c7634cd7fe7dc09338fcec0ca48d816a29d791b0"]:
{{{
#!CommitTicketReference repository=""
revision="c7634cd7fe7dc09338fcec0ca48d816a29d791b0"
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.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/7603#comment:18>

Reply all
Reply to author
Forward
0 new messages