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
a3a4f5c1
Kaydet (Commit)
a3a4f5c1
authored
May 09, 2019
tarafından
Troon
Kaydeden (comit)
Carlton Gibson
May 09, 2019
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #30310 -- Added support for looking up HttpHeaders.headers using underscores.
üst
48235ba8
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
0 deletions
+17
-0
request.py
django/http/request.py
+4
-0
request-response.txt
docs/ref/request-response.txt
+9
-0
3.0.txt
docs/releases/3.0.txt
+3
-0
tests.py
tests/requests/tests.py
+1
-0
No files found.
django/http/request.py
Dosyayı görüntüle @
a3a4f5c1
...
@@ -369,6 +369,10 @@ class HttpHeaders(CaseInsensitiveMapping):
...
@@ -369,6 +369,10 @@ class HttpHeaders(CaseInsensitiveMapping):
headers
[
name
]
=
value
headers
[
name
]
=
value
super
()
.
__init__
(
headers
)
super
()
.
__init__
(
headers
)
def
__getitem__
(
self
,
key
):
"""Allow header lookup using underscores in place of hyphens."""
return
super
()
.
__getitem__
(
key
.
replace
(
'_'
,
'-'
))
@classmethod
@classmethod
def
parse_header_name
(
cls
,
header
):
def
parse_header_name
(
cls
,
header
):
if
header
.
startswith
(
cls
.
HTTP_PREFIX
):
if
header
.
startswith
(
cls
.
HTTP_PREFIX
):
...
...
docs/ref/request-response.txt
Dosyayı görüntüle @
a3a4f5c1
...
@@ -199,6 +199,15 @@ All attributes should be considered read-only, unless stated otherwise.
...
@@ -199,6 +199,15 @@ All attributes should be considered read-only, unless stated otherwise.
>>> request.headers.get('user-agent')
>>> request.headers.get('user-agent')
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6)
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6)
For use in, for example, Django templates, headers can also be looked up
using underscores in place of hyphens::
{{ request.headers.user_agent }}
.. versionchanged:: 3.0
Support for look ups using underscores was added.
.. attribute:: HttpRequest.resolver_match
.. attribute:: HttpRequest.resolver_match
An instance of :class:`~django.urls.ResolverMatch` representing the
An instance of :class:`~django.urls.ResolverMatch` representing the
...
...
docs/releases/3.0.txt
Dosyayı görüntüle @
a3a4f5c1
...
@@ -217,6 +217,9 @@ Requests and Responses
...
@@ -217,6 +217,9 @@ Requests and Responses
* Allowed :class:`~django.http.HttpResponse` to be initialized with
* Allowed :class:`~django.http.HttpResponse` to be initialized with
:class:`memoryview` content.
:class:`memoryview` content.
* For use in, for example, Django templates, :attr:`.HttpRequest.headers` now
allows look ups using underscores (e.g. ``user_agent``) in place of hyphens.
Serialization
Serialization
~~~~~~~~~~~~~
~~~~~~~~~~~~~
...
...
tests/requests/tests.py
Dosyayı görüntüle @
a3a4f5c1
...
@@ -896,6 +896,7 @@ class RequestHeadersTests(SimpleTestCase):
...
@@ -896,6 +896,7 @@ class RequestHeadersTests(SimpleTestCase):
request
=
WSGIRequest
(
self
.
ENVIRON
)
request
=
WSGIRequest
(
self
.
ENVIRON
)
self
.
assertEqual
(
request
.
headers
[
'User-Agent'
],
'python-requests/1.2.0'
)
self
.
assertEqual
(
request
.
headers
[
'User-Agent'
],
'python-requests/1.2.0'
)
self
.
assertEqual
(
request
.
headers
[
'user-agent'
],
'python-requests/1.2.0'
)
self
.
assertEqual
(
request
.
headers
[
'user-agent'
],
'python-requests/1.2.0'
)
self
.
assertEqual
(
request
.
headers
[
'user_agent'
],
'python-requests/1.2.0'
)
self
.
assertEqual
(
request
.
headers
[
'Content-Type'
],
'text/html'
)
self
.
assertEqual
(
request
.
headers
[
'Content-Type'
],
'text/html'
)
self
.
assertEqual
(
request
.
headers
[
'Content-Length'
],
'100'
)
self
.
assertEqual
(
request
.
headers
[
'Content-Length'
],
'100'
)
...
...
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