[CalendarServer-changes] [5130] CalendarServer/trunk/twistedcaldav/client/pool.py
source_changes at macosforge.org
source_changes at macosforge.org
Tue Feb 16 13:45:09 PST 2010
Revision: 5130
http://trac.macosforge.org/projects/calendarserver/changeset/5130
Author: cdaboo at apple.com
Date: 2010-02-16 13:45:07 -0800 (Tue, 16 Feb 2010)
Log Message:
-----------
Use a MemoryStream to store away the original request.stream data so we can replay it if needed.
Modified Paths:
--------------
CalendarServer/trunk/twistedcaldav/client/pool.py
Modified: CalendarServer/trunk/twistedcaldav/client/pool.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/client/pool.py 2010-02-16 21:11:37 UTC (rev 5129)
+++ CalendarServer/trunk/twistedcaldav/client/pool.py 2010-02-16 21:45:07 UTC (rev 5130)
@@ -32,7 +32,9 @@
from twisted.internet.protocol import ClientFactory
from twisted.web2 import responsecode
from twisted.web2.client.http import HTTPClientProtocol
+from twisted.web2.dav.util import allDataFromStream
from twisted.web2.http import StatusResponse, HTTPError
+from twisted.web2.stream import MemoryStream
from twistedcaldav.config import config
class PooledHTTPClientFactory(ClientFactory, LoggingMixIn):
@@ -232,9 +234,17 @@
@return: A L{Deferred} that fires with the result of the given command.
"""
+ # Since we may need to replay the request we have to read the request.stream
+ # into memory and reset request.stream to use a MemoryStream each time we repeat
+ # the request
+ data = (yield allDataFromStream(request.stream))
+
# Try this maxRetries times
for ctr in xrange(self.maxRetries + 1):
try:
+ request.stream = MemoryStream(data if data is not None else "")
+ request.stream.doStartReading = None
+
response = (yield self._submitRequest(request, args, kwargs))
except (ConnectionLost, ConnectionDone, ConnectError), e:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20100216/f8f06743/attachment.html>
More information about the calendarserver-changes
mailing list