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
37809b89
Kaydet (Commit)
37809b89
authored
Kas 05, 2016
tarafından
Adam Malinowski
Kaydeden (comit)
Tim Graham
Kas 05, 2016
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #27346 -- Stopped setting the Content-Length header in ConditionalGetMiddleware.
üst
c7dddc01
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
7 additions
and
35 deletions
+7
-35
AUTHORS
AUTHORS
+1
-0
http.py
django/middleware/http.py
+0
-5
middleware.txt
docs/ref/middleware.txt
+2
-4
1.11.txt
docs/releases/1.11.txt
+4
-2
tests.py
tests/middleware/tests.py
+0
-24
No files found.
AUTHORS
Dosyayı görüntüle @
37809b89
...
...
@@ -9,6 +9,7 @@ answer newbie questions, and generally made Django that much better:
Aaron Swartz <http://www.aaronsw.com/>
Aaron T. Myers <atmyers@gmail.com>
Adam Johnson <https://github.com/adamchainz>
Adam Malinowski <http://adammalinowski.co.uk>
Adam Vandenberg
Adrian Holovaty <adrian@holovaty.com>
Adrien Lemaire <lemaire.adrien@gmail.com>
...
...
django/middleware/http.py
Dosyayı görüntüle @
37809b89
...
...
@@ -11,13 +11,8 @@ class ConditionalGetMiddleware(MiddlewareMixin):
Last-Modified header, and the request has If-None-Match or
If-Modified-Since, the response is replaced by an HttpNotModified. An ETag
header is added if needed.
Also sets the Content-Length response-header.
"""
def
process_response
(
self
,
request
,
response
):
if
not
response
.
streaming
and
not
response
.
has_header
(
'Content-Length'
):
response
[
'Content-Length'
]
=
str
(
len
(
response
.
content
))
# It's too late to prevent an unsafe request with a 412 response, and
# for a HEAD request, the response body is always empty so computing
# an accurate ETag isn't possible.
...
...
docs/ref/middleware.txt
Dosyayı görüntüle @
37809b89
...
...
@@ -181,12 +181,10 @@ header, the middleware adds one if needed. If the response has a ``ETag`` or
``If-Modified-Since``, the response is replaced by an
:class:`~django.http.HttpResponseNotModified`.
Also sets ``Content-Length`` response-header.
.. versionchanged:: 1.11
In older versions, the middleware set the ``
Date`` header and didn't set
the ``ETag`` header.
In older versions, the middleware set the ``
Content-Length`` and ``Date``
headers and didn't set
the ``ETag`` header.
Locale middleware
-----------------
...
...
docs/releases/1.11.txt
Dosyayı görüntüle @
37809b89
...
...
@@ -579,8 +579,10 @@ Miscellaneous
* In the admin templates, ``<p class="help">`` is replaced with a ``<div>`` tag
to allow including lists inside help text.
* ``ConditionalGetMiddleware`` no longer sets the ``Date`` header as Web
servers set that header.
* :class:`~django.middleware.http.ConditionalGetMiddleware` no longer sets the
``Date`` header as Web servers set that header. It also no longer sets the
``Content-Length`` header as this is now done by
:class:`~django.middleware.common.CommonMiddleware`.
* :meth:`~django.apps.AppConfig.get_model` and
:meth:`~django.apps.AppConfig.get_models` now raise
...
...
tests/middleware/tests.py
Dosyayı görüntüle @
37809b89
...
...
@@ -478,30 +478,6 @@ class ConditionalGetMiddlewareTest(SimpleTestCase):
self
.
req
=
RequestFactory
()
.
get
(
'/'
)
self
.
resp
=
self
.
client
.
get
(
self
.
req
.
path_info
)
# Tests for the Content-Length header
def
test_content_length_header_added
(
self
):
content_length
=
len
(
self
.
resp
.
content
)
# Already set by CommonMiddleware, remove it to check that
# ConditionalGetMiddleware readds it.
del
self
.
resp
[
'Content-Length'
]
self
.
assertNotIn
(
'Content-Length'
,
self
.
resp
)
self
.
resp
=
ConditionalGetMiddleware
()
.
process_response
(
self
.
req
,
self
.
resp
)
self
.
assertIn
(
'Content-Length'
,
self
.
resp
)
self
.
assertEqual
(
int
(
self
.
resp
[
'Content-Length'
]),
content_length
)
def
test_content_length_header_not_added
(
self
):
resp
=
StreamingHttpResponse
(
'content'
)
self
.
assertNotIn
(
'Content-Length'
,
resp
)
resp
=
ConditionalGetMiddleware
()
.
process_response
(
self
.
req
,
resp
)
self
.
assertNotIn
(
'Content-Length'
,
resp
)
def
test_content_length_header_not_changed
(
self
):
bad_content_length
=
len
(
self
.
resp
.
content
)
+
10
self
.
resp
[
'Content-Length'
]
=
bad_content_length
self
.
resp
=
ConditionalGetMiddleware
()
.
process_response
(
self
.
req
,
self
.
resp
)
self
.
assertEqual
(
int
(
self
.
resp
[
'Content-Length'
]),
bad_content_length
)
# Tests for the ETag header
def
test_middleware_calculates_etag
(
self
):
...
...
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