Fixed #27345 -- Stopped setting the Date header in ConditionalGetMiddleware.
This commit is contained in:
parent
b679a3cdb1
commit
61f9243e51
|
@ -2,7 +2,7 @@ from django.utils.cache import (
|
|||
cc_delim_re, get_conditional_response, set_response_etag,
|
||||
)
|
||||
from django.utils.deprecation import MiddlewareMixin
|
||||
from django.utils.http import http_date, parse_http_date_safe
|
||||
from django.utils.http import parse_http_date_safe
|
||||
|
||||
|
||||
class ConditionalGetMiddleware(MiddlewareMixin):
|
||||
|
@ -12,10 +12,9 @@ class ConditionalGetMiddleware(MiddlewareMixin):
|
|||
If-Modified-Since, the response is replaced by an HttpNotModified. An ETag
|
||||
header is added if needed.
|
||||
|
||||
Also sets the Date and Content-Length response-headers.
|
||||
Also sets the Content-Length response-header.
|
||||
"""
|
||||
def process_response(self, request, response):
|
||||
response['Date'] = http_date()
|
||||
if not response.streaming and not response.has_header('Content-Length'):
|
||||
response['Content-Length'] = str(len(response.content))
|
||||
|
||||
|
|
|
@ -181,11 +181,12 @@ 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 the ``Date`` and ``Content-Length`` response-headers.
|
||||
Also sets ``Content-Length`` response-header.
|
||||
|
||||
.. versionchanged:: 1.11
|
||||
|
||||
In older versions, the middleware didn't set the ``ETag`` header.
|
||||
In older versions, the middleware set the ``Date`` header and didn't set
|
||||
the ``ETag`` header.
|
||||
|
||||
Locale middleware
|
||||
-----------------
|
||||
|
|
|
@ -559,6 +559,9 @@ 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.
|
||||
|
||||
.. _deprecated-features-1.11:
|
||||
|
||||
Features deprecated in 1.11
|
||||
|
|
|
@ -478,13 +478,6 @@ class ConditionalGetMiddlewareTest(SimpleTestCase):
|
|||
self.req = RequestFactory().get('/')
|
||||
self.resp = self.client.get(self.req.path_info)
|
||||
|
||||
# Tests for the Date header
|
||||
|
||||
def test_date_header_added(self):
|
||||
self.assertNotIn('Date', self.resp)
|
||||
self.resp = ConditionalGetMiddleware().process_response(self.req, self.resp)
|
||||
self.assertIn('Date', self.resp)
|
||||
|
||||
# Tests for the Content-Length header
|
||||
|
||||
def test_content_length_header_added(self):
|
||||
|
|
Loading…
Reference in New Issue