[Zope3-checkins] CVS: Zope3/src/zope/app/http - put.py:1.2

Jim Fulton jim@zope.com
Fri, 28 Feb 2003 17:34:16 -0500


Update of /cvs-repository/Zope3/src/zope/app/http
In directory cvs.zope.org:/tmp/cvs-serv28877

Modified Files:
	put.py 
Log Message:
Changed the add behavior to return a 201 status on success in
accordance to the spec. Thanks to Paul for pointing this out.

Also added a check for any fancy Content-* headers. The spec 
says we should fail if we see any we don't understand.


=== Zope3/src/zope/app/http/put.py 1.1 => 1.2 ===
--- Zope3/src/zope/app/http/put.py:1.1	Fri Feb  7 10:59:37 2003
+++ Zope3/src/zope/app/http/put.py	Fri Feb 28 17:33:45 2003
@@ -46,7 +46,15 @@
         self.request = request
 
     def PUT(self):
-        body = self.request.bodyFile
+        request = self.request
+
+        for name in request:
+            if name.startswith('HTTP_CONTENT_'):
+                # Inimplemented cotent header
+                request.response.setStatus(501)
+                return ''
+
+        body = request.bodyFile
         name = self.context.name
         container = self.context.container
 
@@ -73,12 +81,11 @@
         # XXX Need to add support for large files
         data = body.read()
 
-        newfile = factory(name,
-                          self.request.getHeader('content-type', ''),
-                          data)
+        newfile = factory(name, request.getHeader('content-type', ''), data)
         publish(self.context, ObjectCreatedEvent(newfile))
         dir.setObject(name, newfile)
-        
+
+        request.response.setStatus(201)
         return ''
 
 class FilePUT:
@@ -90,6 +97,14 @@
         self.request = request
 
     def PUT(self):
+        request = self.request
+
+        for name in request:
+            if name.startswith('HTTP_CONTENT_'):
+                # Inimplemented cotent header
+                request.response.setStatus(501)
+                return ''
+
         body = self.request.bodyFile
         file = self.context
         adapter = getAdapter(file, IWriteFile)