Commits

Anonymous committed 4090e57

Werkzeug no longer overrides the Date header when creating a
conditional HTTP response.

Comments (0)

Files changed (3)

   packages properly.
 - disabled automatic socket swiching for IPv6 on the development
   server due to problems it caused.
+- Werkzeug no longer overrides the Date header when creating a
+  conditional HTTP response.
 
 Version 0.6.2
 -------------

tests/test_wrappers.py

     response.headers['Content-Length'] = len(response.data)
     assert response.headers['Cache-Control'] == 'must-revalidate, max-age=60'
 
+    assert 'date' not in response.headers
     env = create_environ()
     env.update({
         'REQUEST_METHOD':       'GET',
         'HTTP_IF_NONE_MATCH':   response.get_etag()[0]
     })
     response.make_conditional(env)
+    assert 'date' in response.headers
 
     # after the thing is invoked by the server as wsgi application
     # (we're emulating this here), there must not be any entity
     assert resp.status_code == 304
     assert not 'content-length' in resp.headers
 
+    # make sure date is not overriden
+    response = Response('Hello World')
+    response.date = 1337
+    d = response.date
+    response.make_conditional(env)
+    assert response.date == d
+
 
 def test_etag_response_mixin_freezing():
     """Freeze of the etag response mixin adds etag if mixed first"""

werkzeug/wrappers.py

         """
         environ = _get_environ(request_or_environ)
         if environ['REQUEST_METHOD'] in ('GET', 'HEAD'):
-            self.headers['Date'] = http_date()
+            # if the date is not in the headers, add it now.  We however
+            # will not override an already existing header.  Unfortunately
+            # will this header be overriden by many WSGI servers including
+            # wsgiref.
+            if 'date' not in self.headers:
+                self.headers['Date'] = http_date()
             if 'content-length' in self.headers:
                 self.headers['Content-Length'] = len(self.data)
             if not is_resource_modified(environ, self.headers.get('etag'), None,