#24459: Add option to `build_absolute_uri` to build specific http or https URI
-------------------------------+--------------------------------
Reporter: rednaw | Owner: nobody
Type: Uncategorized | Status: new
Component: HTTP handling | Version: master
Severity: Normal | Keywords: build_absolute_uri
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------
The `build_absolute_uri` method on the request object
(https://docs.djangoproject.com/en/1.7/ref/request-response/) builds an
absolute URI to the given location. It takes the protocol you're currently
on, so if you are on `http://example.com` and you execute
`build_absolute_uri('test/')` you'll get `http://example.com/test/`, and
if you're on `https://example.com`, you'll get
`https://example.com/test/`.
Sometimes when I create an absolute uri, I want to be sure that it's going
to https, whether I currently am on http or https. So I would like it if I
could tell this to the `build_absolute_uri` method.
I propose to add a keyword agrument `https` to the method. When you set it
to `True` it will use https, when you set it to `False` it will use http,
and when you don't set it it will default to `null`, which will keep the
old behavior (use the protocol that's in use in the current request).
So then you would be able to create a secure absolute URI like this:
{{{
build_absolute_uri('test/', https=True)
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/24459>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/049.e0460575e0cee413ab63f4acd5d11760%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.