[Zope3-checkins] SVN: Zope3/trunk/src/zope/publisher/ Merged from 3.2 branch:

Jim Fulton jim at zope.com
Sat Dec 24 11:58:01 EST 2005


Log message for revision 41034:
  Merged from 3.2 branch:
  
  ------------------------------------------------------------------------
    r41004 | jim | 2005-12-23 16:01:20 -0500 (Fri, 23 Dec 2005) | 3 lines
  
  Changed the stream nagement code to use a StringIO rather than a file
    when the input size is small.
  

Changed:
  U   Zope3/trunk/src/zope/publisher/http.py
  U   Zope3/trunk/src/zope/publisher/tests/test_http.py

-=-
Modified: Zope3/trunk/src/zope/publisher/http.py
===================================================================
--- Zope3/trunk/src/zope/publisher/http.py	2005-12-24 16:57:05 UTC (rev 41033)
+++ Zope3/trunk/src/zope/publisher/http.py	2005-12-24 16:58:00 UTC (rev 41034)
@@ -16,6 +16,7 @@
 $Id$
 """
 import re, time, random
+from cStringIO import StringIO
 from urllib import quote, unquote, splitport
 from types import StringTypes, ClassType
 from cgi import escape
@@ -179,9 +180,13 @@
     This is important, so that we can retry requests.
     """
 
-    def __init__(self, stream):
+    def __init__(self, stream, environment):
         self.stream = stream
-        self.cacheStream = TemporaryFile()
+        size = environment.get('HTTP_CONTENT_LENGTH')
+        if size is None or int(size) < 65536:
+            self.cacheStream = StringIO()
+        else:
+            self.cacheStream = TemporaryFile()
 
     def getCacheStream(self):
         self.read()
@@ -290,7 +295,7 @@
             environ, response = response, outstream
 
         super(HTTPRequest, self).__init__(
-            HTTPInputStream(body_instream), environ, response)
+            HTTPInputStream(body_instream, environ), environ, response)
 
         self._orig_env = environ
         environ = sane_environment(environ)

Modified: Zope3/trunk/src/zope/publisher/tests/test_http.py
===================================================================
--- Zope3/trunk/src/zope/publisher/tests/test_http.py	2005-12-24 16:57:05 UTC (rev 41033)
+++ Zope3/trunk/src/zope/publisher/tests/test_http.py	2005-12-24 16:58:00 UTC (rev 41034)
@@ -58,7 +58,7 @@
 class HTTPInputStreamTests(unittest.TestCase):
 
     def setUp(self):
-        self.stream = HTTPInputStream(StringIO(data))
+        self.stream = HTTPInputStream(StringIO(data), {})
 
     def getCacheStreamValue(self):
         self.stream.cacheStream.seek(0)



More information about the Zope3-Checkins mailing list