[CalendarServer-changes] [5129] CalendarServer/branches/users/cdaboo/deployment-partition-4722/ twistedcaldav/client/pool.py
source_changes at macosforge.org
source_changes at macosforge.org
Tue Feb 16 13:11:38 PST 2010
Revision: 5129
http://trac.macosforge.org/projects/calendarserver/changeset/5129
Author: cdaboo at apple.com
Date: 2010-02-16 13:11:37 -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/branches/users/cdaboo/deployment-partition-4722/twistedcaldav/client/pool.py
Modified: CalendarServer/branches/users/cdaboo/deployment-partition-4722/twistedcaldav/client/pool.py
===================================================================
--- CalendarServer/branches/users/cdaboo/deployment-partition-4722/twistedcaldav/client/pool.py 2010-02-16 21:08:19 UTC (rev 5128)
+++ CalendarServer/branches/users/cdaboo/deployment-partition-4722/twistedcaldav/client/pool.py 2010-02-16 21:11:37 UTC (rev 5129)
@@ -27,7 +27,9 @@
from twisted.internet.ssl import DefaultOpenSSLContextFactory
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.log import LoggingMixIn
import OpenSSL
import urlparse
@@ -230,9 +232,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:
self.log_error("HTTP pooled client connection error (attempt: %d) - retrying: %s" % (ctr+1, e,))
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20100216/993ed7a8/attachment.html>
More information about the calendarserver-changes
mailing list