[Checkins] SVN: z3c.dav/trunk/src/z3c/dav/ The content length can
be a string that needs to be converted to an integer.
Michael Kerrin
michael.kerrin at openapp.ie
Mon Jul 2 14:57:22 EDT 2007
Log message for revision 77312:
The content length can be a string that needs to be converted to an integer.
Fix bug in documentation layout.
Changed:
U z3c.dav/trunk/src/z3c/dav/README.txt
U z3c.dav/trunk/src/z3c/dav/publisher.py
U z3c.dav/trunk/src/z3c/dav/tests/test_publisher.py
-=-
Modified: z3c.dav/trunk/src/z3c/dav/README.txt
===================================================================
--- z3c.dav/trunk/src/z3c/dav/README.txt 2007-07-02 18:53:39 UTC (rev 77311)
+++ z3c.dav/trunk/src/z3c/dav/README.txt 2007-07-02 18:57:22 UTC (rev 77312)
@@ -9,7 +9,7 @@
the ability to handle WebDAV specific errors, to generate multi-status
responses, and an implementation of all core WebDAV methods exist that use
zope component to lookup specific adapters that perform the required action.
-For example `locking`_ parses the request and then looks up a IDAVLockmanager
+For example locking parses the request and then looks up a IDAVLockmanager
adapter to perform the locking and unlocking of objects. But if the required
adapter does not exist then a `405 Method Not Allowed` response is returned
to the client.
Modified: z3c.dav/trunk/src/z3c/dav/publisher.py
===================================================================
--- z3c.dav/trunk/src/z3c/dav/publisher.py 2007-07-02 18:53:39 UTC (rev 77311)
+++ z3c.dav/trunk/src/z3c/dav/publisher.py 2007-07-02 18:57:22 UTC (rev 77312)
@@ -55,8 +55,12 @@
content_type = parts[0].strip().lower()
content_type_params = parts[1].strip()
+ content_length = self.getHeader("content-length", 0)
+ if content_length:
+ content_length = int(content_length)
+
if content_type in ("text/xml", "application/xml", None) and \
- self.getHeader("content-length", 0) > 0:
+ content_length > 0:
etree = z3c.etree.getEngine()
try:
self.xmlDataSource = etree.parse(self.bodyStream).getroot()
Modified: z3c.dav/trunk/src/z3c/dav/tests/test_publisher.py
===================================================================
--- z3c.dav/trunk/src/z3c/dav/tests/test_publisher.py 2007-07-02 18:53:39 UTC (rev 77311)
+++ z3c.dav/trunk/src/z3c/dav/tests/test_publisher.py 2007-07-02 18:57:22 UTC (rev 77312)
@@ -118,7 +118,26 @@
self.assertRaises(BadRequest, request.processInputs)
self.assertEqual(request.content_type, None)
+ def test_contentLength(self):
+ request = create_request("", {"CONTENT_TYPE": "text/xml",
+ "CONTENT_LENGTH": "0"})
+ request.processInputs()
+ self.assertEqual(request.content_type, "text/xml")
+ self.assertEqual(request.xmlDataSource, None)
+
+ def test_contentLength2(self):
+ body = """<?xml version="1.0" encoding="utf-8" ?>
+ <somedoc>This is some xml document</somedoc>
+ """
+ request = create_request(body, {"CONTENT_TYPE": "text/xml",
+ "CONTENT_LENGTH": str(len(body))})
+ request.processInputs()
+
+ self.assertEqual(request.content_type, "text/xml")
+ self.assert_(request.xmlDataSource is not None)
+
+
def test_suite():
return unittest.TestSuite((
unittest.makeSuite(TestWebDAVPublisher),
More information about the Checkins
mailing list