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

source_changes at macosforge.org source_changes at macosforge.org
Mon Nov 29 13:26:21 PST 2010


Revision: 6660
          http://trac.macosforge.org/projects/calendarserver/changeset/6660
Author:   exarkun at twistedmatrix.com
Date:     2010-11-29 13:26:18 -0800 (Mon, 29 Nov 2010)
Log Message:
-----------
Make the response body available via readBody

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

Modified: CalendarServer/trunk/contrib/performance/httpclient.py
===================================================================
--- CalendarServer/trunk/contrib/performance/httpclient.py	2010-11-29 20:24:18 UTC (rev 6659)
+++ CalendarServer/trunk/contrib/performance/httpclient.py	2010-11-29 21:26:18 UTC (rev 6660)
@@ -14,23 +14,26 @@
 # limitations under the License.
 ##
 
+from StringIO import StringIO
+
 from zope.interface import implements
 
 from twisted.internet.protocol import Protocol
 from twisted.internet.defer import Deferred, succeed
 from twisted.web.iweb import IBodyProducer
 
-class _DiscardReader(Protocol):
+class _BufferReader(Protocol):
     def __init__(self, finished):
         self.finished = finished
+        self.received = StringIO()
 
 
     def dataReceived(self, bytes):
-        pass
+        self.received.write(bytes)
 
 
     def connectionLost(self, reason):
-        self.finished.callback(None)
+        self.finished.callback(self.received.getvalue())
 
 
 
@@ -38,7 +41,7 @@
     if response.length == 0:
         return succeed(None)
     finished = Deferred()
-    response.deliverBody(_DiscardReader(finished))
+    response.deliverBody(_BufferReader(finished))
     return finished
 
 
@@ -54,5 +57,3 @@
     def startProducing(self, consumer):
         consumer.write(self._body)
         return succeed(None)
-
-
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20101129/20163e43/attachment.html>


More information about the calendarserver-changes mailing list