[Zope3-checkins] CVS: Zope3/src/zope/publisher - http.py:1.45

Stephan Richter srichter at cosmos.phy.tufts.edu
Sat Mar 20 11:27:18 EST 2004


Update of /cvs-repository/Zope3/src/zope/publisher
In directory cvs.zope.org:/tmp/cvs-serv11314/src/zope/publisher

Modified Files:
	http.py 
Log Message:


Set default response code to None; check the HTTP version of the request for
intelligently defaulting to 302 or 303.




=== Zope3/src/zope/publisher/http.py 1.44 => 1.45 ===
--- Zope3/src/zope/publisher/http.py:1.44	Fri Mar 19 15:26:43 2004
+++ Zope3/src/zope/publisher/http.py	Sat Mar 20 11:27:18 2004
@@ -11,7 +11,7 @@
 # FOR A PARTICULAR PURPOSE.
 #
 ##############################################################################
-"""
+"""HTTP Publisher
 
 $Id$
 """
@@ -851,8 +851,16 @@
             blen = blen[:-1]
         self.setHeader('content-length', blen)
 
-    def redirect(self, location, status=302):
+    def redirect(self, location, status=None):
         """Causes a redirection without raising an error"""
+        if status is None:
+            # parse the HTTP version and set default accordingly
+            if (self._request.get("SERVER_PROTOCOL","HTTP/1.0") <
+                "HTTP/1.1"):
+                status=302
+            else:
+                status=303
+                
         self.setStatus(status)
         self.setHeader('Location', location)
         return location
@@ -899,7 +907,6 @@
 
     def outputHeaders(self):
         """This method outputs all headers.
-
         Since it is a final output method, it must take care of all possible
         unicode strings and encode them! 
         """




More information about the Zope3-Checkins mailing list