diff --git a/django/middleware/http.py b/django/middleware/http.py index 2f9186f82c..a075ccfe79 100644 --- a/django/middleware/http.py +++ b/django/middleware/http.py @@ -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)) diff --git a/docs/ref/middleware.txt b/docs/ref/middleware.txt index d007d252f5..71e888e928 100644 --- a/docs/ref/middleware.txt +++ b/docs/ref/middleware.txt @@ -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 ----------------- diff --git a/docs/releases/1.11.txt b/docs/releases/1.11.txt index 3be654eff5..a83bace8b6 100644 --- a/docs/releases/1.11.txt +++ b/docs/releases/1.11.txt @@ -559,6 +559,9 @@ Miscellaneous * In the admin templates, ``

`` is replaced with a ``

`` 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 diff --git a/tests/middleware/tests.py b/tests/middleware/tests.py index 12109b3137..7adf4b3a77 100644 --- a/tests/middleware/tests.py +++ b/tests/middleware/tests.py @@ -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):