[Checkins] SVN: zope.publisher/trunk/ Don't guess the content type with 304 responses which MUST NOT /
Brian Sutherland
cvs-admin at zope.org
Thu Sep 6 09:44:56 UTC 2012
Log message for revision 127747:
Don't guess the content type with 304 responses which MUST NOT /
SHOULD NOT include it according to:
http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.5
Unfortunately, the content type will still be guessed if the result is
set before the status.
Changed:
U zope.publisher/trunk/CHANGES.txt
U zope.publisher/trunk/src/zope/publisher/browser.py
U zope.publisher/trunk/src/zope/publisher/tests/test_browserresponse.py
-=-
Modified: zope.publisher/trunk/CHANGES.txt
===================================================================
--- zope.publisher/trunk/CHANGES.txt 2012-09-06 09:40:11 UTC (rev 127746)
+++ zope.publisher/trunk/CHANGES.txt 2012-09-06 09:44:52 UTC (rev 127747)
@@ -14,7 +14,13 @@
- Wrap ``with interaction()`` in try/finally.
+- Don't guess the content type with 304 responses which MUST NOT /
+ SHOULD NOT include it according to:
+ http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.5
+ Unfortunately, the content type will still be guessed if the result is
+ set before the status.
+
3.13.0 (2011-11-17)
-------------------
Modified: zope.publisher/trunk/src/zope/publisher/browser.py
===================================================================
--- zope.publisher/trunk/src/zope/publisher/browser.py 2012-09-06 09:40:11 UTC (rev 127746)
+++ zope.publisher/trunk/src/zope/publisher/browser.py 2012-09-06 09:44:52 UTC (rev 127747)
@@ -694,7 +694,7 @@
def _implicitResult(self, body):
content_type = self.getHeader('content-type')
- if content_type is None:
+ if content_type is None and self._status != 304:
if isHTML(body):
content_type = 'text/html'
else:
Modified: zope.publisher/trunk/src/zope/publisher/tests/test_browserresponse.py
===================================================================
--- zope.publisher/trunk/src/zope/publisher/tests/test_browserresponse.py 2012-09-06 09:40:11 UTC (rev 127746)
+++ zope.publisher/trunk/src/zope/publisher/tests/test_browserresponse.py 2012-09-06 09:44:52 UTC (rev 127747)
@@ -85,6 +85,18 @@
response.getHeader('content-type').startswith("text/plain")
)
+ def test_not_DWIM_for_304_response(self):
+ # Don't guess the content type with 304 responses which MUST NOT /
+ # SHOULD NOT include it.
+ #
+ # http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.5
+ #
+ # NOTE: The content type is sill guessed if status us set after
+ # the result :(
+ response = BrowserResponse()
+ response.setStatus(304)
+ response.setResult('')
+ self.assertEqual(response.getHeader('content-type'), None)
def testInsertBase(self):
response = BrowserResponse()
More information about the checkins
mailing list