[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/http/ Allow requests with keys begining with HTTP_CONTENT_ when

Michael Kerrin michael.kerrin at openapp.biz
Tue Oct 25 09:47:24 EDT 2005


Log message for revision 39612:
  Allow requests with keys begining with HTTP_CONTENT_ when
  performaing a PUT command.
  

Changed:
  U   Zope3/trunk/src/zope/app/http/put.py
  U   Zope3/trunk/src/zope/app/http/tests/test_put.py

-=-
Modified: Zope3/trunk/src/zope/app/http/put.py
===================================================================
--- Zope3/trunk/src/zope/app/http/put.py	2005-10-25 12:41:20 UTC (rev 39611)
+++ Zope3/trunk/src/zope/app/http/put.py	2005-10-25 13:47:23 UTC (rev 39612)
@@ -47,12 +47,6 @@
     def PUT(self):
         request = self.request
 
-        for name in request:
-            if name.startswith('HTTP_CONTENT_'):
-                # Unimplemented content header
-                request.response.setStatus(501)
-                return ''
-
         body = request.bodyStream
         name = self.context.name
         container = self.context.container
@@ -96,12 +90,6 @@
     def PUT(self):
         request = self.request
 
-        for name in request:
-            if name.startswith('HTTP_CONTENT_'):
-                # Unimplemented content header
-                request.response.setStatus(501)
-                return ''
-
         body = self.request.bodyStream
         file = self.context
         adapter = IWriteFile(file)

Modified: Zope3/trunk/src/zope/app/http/tests/test_put.py
===================================================================
--- Zope3/trunk/src/zope/app/http/tests/test_put.py	2005-10-25 12:41:20 UTC (rev 39611)
+++ Zope3/trunk/src/zope/app/http/tests/test_put.py	2005-10-25 13:47:23 UTC (rev 39612)
@@ -71,6 +71,10 @@
         self.assertEqual(request.response.getStatus(), 201)
 
     def test_bad_content_header(self):
+        ## The previous behavour of the PUT method was to fail if the request
+        ## object had a key beginning with 'HTTP_CONTENT_' with a status of 501.
+        ## This was breaking the new Twisted server, so I am now allowing this
+        ## this type of request to be valid.
         container = Container()
         content = "some content\n for testing"
         request = TestRequest(StringIO(content),
@@ -85,7 +89,7 @@
         request.response.setResult('')
 
         # Check HTTP Response
-        self.assertEqual(request.response.getStatus(), 501)
+        self.assertEqual(request.response.getStatus(), 201)
 
 class TestFilePUT(PlacelessSetup, TestCase):
 
@@ -102,6 +106,10 @@
         self.assertEqual(file.data, content)
 
     def test_bad_content_header(self):
+        ## The previous behavour of the PUT method was to fail if the request
+        ## object had a key beginning with 'HTTP_CONTENT_' with a status of 501.
+        ## This was breaking the new Twisted server, so I am now allowing this
+        ## this type of request to be valid.
         file = File("thefile", "text/x", "initial content")
         content = "some content\n for testing"
         request = TestRequest(StringIO(content),
@@ -112,10 +120,10 @@
         put = zope.app.http.put.FilePUT(file, request)
         self.assertEqual(put.PUT(), '')
         request.response.setResult('')
-        self.assertEqual(file.data, "initial content")
+        self.assertEqual(file.data, content)
 
         # Check HTTP Response
-        self.assertEqual(request.response.getStatus(), 501)
+        self.assertEqual(request.response.getStatus(), 200)
 
 def test_suite():
     return TestSuite((



More information about the Zope3-Checkins mailing list