[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/twisted/ Merged from
3.2 branch:
Jim Fulton
jim at zope.com
Tue Jan 3 14:01:57 EST 2006
Log message for revision 41110:
Merged from 3.2 branch:
r41058 | jim | 2005-12-31 14:29:21 -0500 (Sat, 31 Dec 2005) | 3 lines
Fixed a bug in the twisted prebuffering. The mmap wrapper has some
problems. We avoid those by just not using it.
Changed:
U Zope3/trunk/src/zope/app/twisted/http.py
U Zope3/trunk/src/zope/app/twisted/tests/test_inputbuffering.py
-=-
Modified: Zope3/trunk/src/zope/app/twisted/http.py
===================================================================
--- Zope3/trunk/src/zope/app/twisted/http.py 2006-01-03 18:58:37 UTC (rev 41109)
+++ Zope3/trunk/src/zope/app/twisted/http.py 2006-01-03 19:01:56 UTC (rev 41110)
@@ -38,7 +38,7 @@
def done(_):
temp.seek(0)
# Replace the request's stream object with the tempfile
- req.stream = stream.FileStream(temp)
+ req.stream = stream.FileStream(temp, useMMap=False)
# Hm, this shouldn't be required:
req.stream.doStartReading = None
Modified: Zope3/trunk/src/zope/app/twisted/tests/test_inputbuffering.py
===================================================================
--- Zope3/trunk/src/zope/app/twisted/tests/test_inputbuffering.py 2006-01-03 18:58:37 UTC (rev 41109)
+++ Zope3/trunk/src/zope/app/twisted/tests/test_inputbuffering.py 2006-01-03 19:01:56 UTC (rev 41110)
@@ -13,8 +13,10 @@
##############################################################################
r"""Meke sure that input is buffered
-Meke sure that input is buffered, so that a slow client doesn't block an application thread.
+Meke sure that input is buffered, so that a slow client doesn't block
+an application thread.
+Also, test that both small and (somewhat) large inputs are handled correctly.
>>> instance = Instance()
>>> instance.start()
@@ -29,7 +31,7 @@
>>> bad.sendall('Content-Length: 10\r\n')
>>> bad.sendall('Content-Type: text/plain\r\n')
>>> bad.sendall('\r\n')
- >>> bad.sendall('x')
+ >>> bad.sendall('x\r\n')
At this point, the request shouldn't be in a thread yet, so we should be
able to make another request:
@@ -39,22 +41,22 @@
>>> s.connect(('localhost', instance.port))
>>> s.sendall('GET http://localhost:%s/echo HTTP/1.1\r\n'
... % instance.port)
- >>> s.sendall('Content-Length: 10\r\n')
+ >>> s.sendall('Content-Length: 120005\r\n')
>>> s.sendall('Content-Type: text/plain\r\n')
>>> s.sendall('\r\n')
- >>> s.sendall('xxxxxxxxxxxxxxx\n')
+ >>> s.sendall('xxxxxxxxxx\r\n' * 10000 + 'end\r\n')
>>> f = s.makefile()
>>> f.readline()
'HTTP/1.1 200 OK\r\n'
>>> message = rfc822.Message(f)
>>> message['content-length']
- '10'
+ '120000'
>>> s.close()
- >>> bad.sendall('xxxxxxxxxx\n')
+ >>> bad.sendall('end\r\n' + 'xxxxxxxxxx\n')
>>> bad.close()
>>> instance.stop()
>>> shutil.rmtree(instance.dir)
@@ -81,7 +83,17 @@
self.request = request
def echo(self):
- return self.request.bodyStream.read()
+ s = 0
+ result = []
+ while 1:
+ l = self.request.bodyStream.readline()
+ s += len(l)
+ if l and l != 'end\r\n':
+ result.append(l)
+ else:
+ break
+
+ return ''.join(result)
More information about the Zope3-Checkins
mailing list