Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
django
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
django
Commits
5bf62825
Kaydet (Commit)
5bf62825
authored
Kas 22, 2017
tarafından
George-Cristian Bîrzan
Kaydeden (comit)
Tim Graham
Ock 10, 2018
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #28828 -- Improved performance of HttpRequest.build_absolute_uri().
üst
a613feb5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
7 deletions
+21
-7
request.py
django/http/request.py
+21
-7
No files found.
django/http/request.py
Dosyayı görüntüle @
5bf62825
...
...
@@ -15,6 +15,7 @@ from django.http.multipartparser import MultiPartParser, MultiPartParserError
from
django.utils.datastructures
import
ImmutableList
,
MultiValueDict
from
django.utils.deprecation
import
RemovedInDjango30Warning
from
django.utils.encoding
import
escape_uri_path
,
force_bytes
,
iri_to_uri
from
django.utils.functional
import
cached_property
from
django.utils.http
import
is_same_domain
,
limited_parse_qsl
RAISE_ERROR
=
object
()
...
...
@@ -176,15 +177,28 @@ class HttpRequest:
location
=
'//
%
s'
%
self
.
get_full_path
()
bits
=
urlsplit
(
location
)
if
not
(
bits
.
scheme
and
bits
.
netloc
):
current_uri
=
'{scheme}://{host}{path}'
.
format
(
scheme
=
self
.
scheme
,
host
=
self
.
get_host
(),
path
=
self
.
path
)
# Join the constructed URL with the provided location, which will
# allow the provided ``location`` to apply query strings to the
# base path as well as override the host, if it begins with //
location
=
urljoin
(
current_uri
,
location
)
# Handle the simple, most common case. If the location is absolute
# and a scheme or host (netloc) isn't provided, skip an expensive
# urljoin() as long as no path segments are '.' or '..'.
if
(
bits
.
path
.
startswith
(
'/'
)
and
not
bits
.
scheme
and
not
bits
.
netloc
and
'/./'
not
in
bits
.
path
and
'/../'
not
in
bits
.
path
):
# If location starts with '//' but has no netloc, reuse the
# schema and netloc from the current request. Strip the double
# slashes and continue as if it wasn't specified.
if
location
.
startswith
(
'//'
):
location
=
location
[
2
:]
location
=
self
.
_current_scheme_host
+
location
else
:
# Join the constructed URL with the provided location, which
# allows the provided location to apply query strings to the
# base path.
location
=
urljoin
(
self
.
_current_scheme_host
+
self
.
path
,
location
)
return
iri_to_uri
(
location
)
@cached_property
def
_current_scheme_host
(
self
):
return
'{}://{}'
.
format
(
self
.
scheme
,
self
.
get_host
())
def
_get_scheme
(
self
):
"""
Hook for subclasses like WSGIRequest to implement. Return 'http' by
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment