[CalendarServer-changes] [6835] CalendarServer/trunk/contrib/performance/httpclient.py

source_changes at macosforge.org source_changes at macosforge.org
Mon Jan 31 12:23:01 PST 2011


Revision: 6835
          http://trac.macosforge.org/projects/calendarserver/changeset/6835
Author:   exarkun at twistedmatrix.com
Date:     2011-01-31 12:23:00 -0800 (Mon, 31 Jan 2011)
Log Message:
-----------
Add the MemoryConsumer used by the unit tests to ensure the right data is sent in the request body.

Modified Paths:
--------------
    CalendarServer/trunk/contrib/performance/httpclient.py

Modified: CalendarServer/trunk/contrib/performance/httpclient.py
===================================================================
--- CalendarServer/trunk/contrib/performance/httpclient.py	2011-01-29 01:40:57 UTC (rev 6834)
+++ CalendarServer/trunk/contrib/performance/httpclient.py	2011-01-31 20:23:00 UTC (rev 6835)
@@ -21,7 +21,9 @@
 from twisted.internet.protocol import Protocol
 from twisted.internet.defer import Deferred, succeed
 from twisted.web.iweb import IBodyProducer
+from twisted.internet.interfaces import IConsumer
 
+
 class _BufferReader(Protocol):
     def __init__(self, finished):
         self.finished = finished
@@ -60,3 +62,21 @@
     def startProducing(self, consumer):
         consumer.write(self._body)
         return succeed(None)
+
+
+
+class MemoryConsumer(object):
+    implements(IConsumer)
+
+    def __init__(self):
+        self._buffer = []
+
+
+    def write(self, bytes):
+        self._buffer.append(bytes)
+
+
+    def value(self):
+        if len(self._buffer) > 1:
+            self._buffer = ["".join(self._buffer)]
+        return "".join(self._buffer)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110131/0cf8436a/attachment.html>


More information about the calendarserver-changes mailing list