Log message for revision 87396: Launchpad #239636: Ensure that HEAD requests lock an empty body for NotFound errors.
Changed: U Zope/branches/2.9/doc/CHANGES.txt U Zope/branches/2.9/lib/python/webdav/NullResource.py U Zope/branches/2.9/lib/python/webdav/tests/testNullResource.py -=- Modified: Zope/branches/2.9/doc/CHANGES.txt =================================================================== --- Zope/branches/2.9/doc/CHANGES.txt 2008-06-14 17:24:19 UTC (rev 87395) +++ Zope/branches/2.9/doc/CHANGES.txt 2008-06-14 17:44:34 UTC (rev 87396) @@ -8,6 +8,9 @@ Bugs fixed + - Launchpad #239636: Ensure that HEAD requests lock an empty body + for NotFound errors. + - Launchpad #234209: De-tabify ZPublisher/HTTPRequest.py Zope 2.9.9 (2008/05/10) Modified: Zope/branches/2.9/lib/python/webdav/NullResource.py =================================================================== --- Zope/branches/2.9/lib/python/webdav/NullResource.py 2008-06-14 17:24:19 UTC (rev 87395) +++ Zope/branches/2.9/lib/python/webdav/NullResource.py 2008-06-14 17:44:34 UTC (rev 87396) @@ -68,6 +68,7 @@ def HEAD(self, REQUEST, RESPONSE): """Retrieve resource information without a response message body.""" self.dav__init(REQUEST, RESPONSE) + RESPONSE.setBody('', lock=True) raise NotFound, 'The requested resource does not exist.' # Most methods return 404 (Not Found) for null resources. Modified: Zope/branches/2.9/lib/python/webdav/tests/testNullResource.py =================================================================== --- Zope/branches/2.9/lib/python/webdav/tests/testNullResource.py 2008-06-14 17:24:19 UTC (rev 87395) +++ Zope/branches/2.9/lib/python/webdav/tests/testNullResource.py 2008-06-14 17:44:34 UTC (rev 87396) @@ -20,21 +20,47 @@ class TestNullResource(unittest.TestCase): + def _getTargetClass(self): + from webdav.NullResource import NullResource + return NullResource + + def _makeOne(self, parent=None, name='nonesuch', **kw): + return self._getTargetClass()(parent, name, **kw) + def test_z2interfaces(self): from Interface.Verify import verifyClass - from webdav.NullResource import NullResource from webdav.WriteLockInterface import WriteLockInterface - verifyClass(WriteLockInterface, NullResource) + verifyClass(WriteLockInterface, self._getTargetClass()) def test_z3interfaces(self): from webdav.interfaces import IWriteLock - from webdav.NullResource import NullResource from zope.interface.verify import verifyClass - verifyClass(IWriteLock, NullResource) + verifyClass(IWriteLock, self._getTargetClass()) + def test_HEAD_locks_empty_body_before_raising_NotFound(self): + from zExceptions import NotFound + # See https://bugs.launchpad.net/bugs/239636 + class DummyResponse: + _server_version = 'Dummy' # emulate ZServer response + locked = False + body = None + def setHeader(self, *args): + pass + def setBody(self, body, lock=False): + self.body = body + self.locked = bool(lock) + nonesuch = self._makeOne() + request = {} + response = DummyResponse() + + self.assertRaises(NotFound, nonesuch.HEAD, request, response) + + self.assertEqual(response.body, '') + self.failUnless(response.locked) + def test_suite(): return unittest.TestSuite(( unittest.makeSuite(TestLockNullResource), _______________________________________________ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins