[CalendarServer-changes] [10597] CalendarServer/trunk/twistedcaldav/client/geturl.py

source_changes at macosforge.org source_changes at macosforge.org
Tue Jan 29 10:28:17 PST 2013


Revision: 10597
          http://trac.calendarserver.org//changeset/10597
Author:   cdaboo at apple.com
Date:     2013-01-29 10:28:17 -0800 (Tue, 29 Jan 2013)
Log Message:
-----------
Handle possible unicode URLs.

Modified Paths:
--------------
    CalendarServer/trunk/twistedcaldav/client/geturl.py

Modified: CalendarServer/trunk/twistedcaldav/client/geturl.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/client/geturl.py	2013-01-29 03:35:09 UTC (rev 10596)
+++ CalendarServer/trunk/twistedcaldav/client/geturl.py	2013-01-29 18:28:17 UTC (rev 10597)
@@ -62,9 +62,11 @@
             self.factory.protocolConnectionMade = None
             d.callback(self)
 
+
     def dataReceived(self, data):
         self.data += data
 
+
     def connectionLost(self, reason):
         self.closed = 1
         self.closedReason = reason
@@ -72,12 +74,16 @@
             d, self.closedDeferred = self.closedDeferred, None
             d.callback(None)
 
+
+
 @inlineCallbacks
 def getURL(url, method="GET", redirect=0):
 
+    if isinstance(url, unicode):
+        url = url.encode("utf-8")
     agent = Agent(reactor)
     headers = http_headers.Headers({})
-    
+
     try:
         response = (yield agent.request(method, url, headers, None))
     except Exception, e:
@@ -90,14 +96,14 @@
             else:
                 location = response.headers.getRawHeaders("location")
                 if location:
-                    newresponse = (yield getURL(location[0], method=method, redirect=redirect+1))
+                    newresponse = (yield getURL(location[0], method=method, redirect=redirect + 1))
                     if response.code == MOVED_PERMANENTLY:
                         scheme, netloc, url, _ignore_params, _ignore_query, _ignore_fragment = urlparse(location[0])
                         newresponse.location = urlunparse((scheme, netloc, url, None, None, None,))
                     returnValue(newresponse)
                 else:
                     log.err("Redirect without a Location header")
-    
+
     if response is not None and response.code / 100 == 2:
         protocol = AccumulatingProtocol()
         response.deliverBody(protocol)
@@ -106,6 +112,5 @@
         response.data = protocol.data
     else:
         log.error("Failed getURL: %s" % (url,))
-        
+
     returnValue(response)
-
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20130129/061a7d80/attachment.html>


More information about the calendarserver-changes mailing list