[Zope3-checkins] SVN: Zope3/branches/3.2/src/zope/publisher/
Changed the stream nagement code to use a StringIO rather
than a file
Jim Fulton
jim at zope.com
Fri Dec 23 16:01:21 EST 2005
Log message for revision 41004:
Changed the stream nagement code to use a StringIO rather than a file
when the input size is small.
Changed:
U Zope3/branches/3.2/src/zope/publisher/http.py
U Zope3/branches/3.2/src/zope/publisher/tests/test_http.py
-=-
Modified: Zope3/branches/3.2/src/zope/publisher/http.py
===================================================================
--- Zope3/branches/3.2/src/zope/publisher/http.py 2005-12-23 21:01:18 UTC (rev 41003)
+++ Zope3/branches/3.2/src/zope/publisher/http.py 2005-12-23 21:01:20 UTC (rev 41004)
@@ -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/branches/3.2/src/zope/publisher/tests/test_http.py
===================================================================
--- Zope3/branches/3.2/src/zope/publisher/tests/test_http.py 2005-12-23 21:01:18 UTC (rev 41003)
+++ Zope3/branches/3.2/src/zope/publisher/tests/test_http.py 2005-12-23 21:01:20 UTC (rev 41004)
@@ -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