[CalendarServer-changes] [3189] CalendarServer/trunk

source_changes at macosforge.org source_changes at macosforge.org
Sat Oct 18 18:11:29 PDT 2008


Revision: 3189
          http://trac.macosforge.org/projects/calendarserver/changeset/3189
Author:   cdaboo at apple.com
Date:     2008-10-18 18:11:29 -0700 (Sat, 18 Oct 2008)
Log Message:
-----------
Preserve parameters on Content-Type headers.

Modified Paths:
--------------
    CalendarServer/trunk/lib-patches/Twisted/twisted.web2.dav.method.put_common.patch
    CalendarServer/trunk/lib-patches/Twisted/twisted.web2.dav.resource.patch
    CalendarServer/trunk/twistedcaldav/method/put_common.py

Modified: CalendarServer/trunk/lib-patches/Twisted/twisted.web2.dav.method.put_common.patch
===================================================================
--- CalendarServer/trunk/lib-patches/Twisted/twisted.web2.dav.method.put_common.patch	2008-10-18 02:09:15 UTC (rev 3188)
+++ CalendarServer/trunk/lib-patches/Twisted/twisted.web2.dav.method.put_common.patch	2008-10-19 01:11:29 UTC (rev 3189)
@@ -2,7 +2,7 @@
 ===================================================================
 --- twisted/web2/dav/method/put_common.py	(revision 0)
 +++ twisted/web2/dav/method/put_common.py	(revision 0)
-@@ -0,0 +1,266 @@
+@@ -0,0 +1,267 @@
 +##
 +# Copyright (c) 2005-2007 Apple Inc. All rights reserved.
 +#
@@ -40,6 +40,7 @@
 +from twisted.web2.dav.resource import TwistedGETContentMD5
 +from twisted.web2.dav.stream import MD5StreamWrapper
 +from twisted.web2.http import HTTPError
++from twisted.web2.http_headers import generateContentType
 +from twisted.web2.iweb import IResponse
 +from twisted.web2.stream import MemoryStream
 +
@@ -227,7 +228,7 @@
 +        if source is None:
 +            content_type = request.headers.getHeader("content-type")
 +            if content_type is not None:
-+                destination.writeDeadProperty(davxml.GETContentType.fromString("%s/%s" % (content_type.mediaType, content_type.mediaSubtype,)))
++                destination.writeDeadProperty(davxml.GETContentType.fromString(generateContentType(content_type)))
 +
 +        response = IResponse(response)
 +        

Modified: CalendarServer/trunk/lib-patches/Twisted/twisted.web2.dav.resource.patch
===================================================================
--- CalendarServer/trunk/lib-patches/Twisted/twisted.web2.dav.resource.patch	2008-10-18 02:09:15 UTC (rev 3188)
+++ CalendarServer/trunk/lib-patches/Twisted/twisted.web2.dav.resource.patch	2008-10-19 01:11:29 UTC (rev 3189)
@@ -76,7 +76,15 @@
          return succeed(qname in self.liveProperties or self.deadProperties().contains(qname))
  
      def readProperty(self, property, request):
-@@ -239,8 +260,10 @@
+@@ -201,7 +222,6 @@
+                     mimeType = self.contentType()
+                     if mimeType is None:
+                         return None
+-                    mimeType.params = None # WebDAV getcontenttype property does not include parameters
+                     return davxml.GETContentType(generateContentType(mimeType))
+ 
+                 if name == "getcontentlength":
+@@ -239,8 +259,10 @@
                      )
  
                  if name == "supported-report-set":
@@ -89,7 +97,7 @@
  
                  if name == "supported-privilege-set":
                      return self.supportedPrivileges(request)
-@@ -252,9 +275,10 @@
+@@ -252,9 +274,10 @@
                      return davxml.InheritedACLSet(*self.inheritedACLSet())
  
                  if name == "principal-collection-set":
@@ -103,7 +111,7 @@
  
                  def ifAllowed(privileges, callback):
                      def onError(failure):
-@@ -286,7 +310,36 @@
+@@ -286,7 +309,36 @@
                          d.addCallback(gotACL)
                          return d
                      return ifAllowed((davxml.ReadACL(),), callback)
@@ -140,7 +148,7 @@
              elif namespace == twisted_dav_namespace:
                  if name == "resource-class":
                      class ResourceClass (davxml.WebDAVTextElement):
-@@ -309,10 +362,7 @@
+@@ -309,10 +361,7 @@
          """
          See L{IDAVResource.writeProperty}.
          """
@@ -152,7 +160,7 @@
  
          def defer():
              if property.protected:
-@@ -363,15 +413,28 @@
+@@ -363,15 +412,28 @@
          """
          See L{IDAVResource.listProperties}.
          """
@@ -185,7 +193,7 @@
      def listAllprop(self, request):
          """
          Some DAV properties should not be returned to a C{DAV:allprop} query.
-@@ -465,8 +528,22 @@
+@@ -465,8 +527,22 @@
              return super(DAVPropertyMixIn, self).displayName()
  
  class DAVResource (DAVPropertyMixIn, StaticRenderMixin):
@@ -208,7 +216,7 @@
      ##
      # DAV
      ##
-@@ -553,12 +630,13 @@
+@@ -553,12 +629,13 @@
      def supportedReports(self):
          """
          See L{IDAVResource.supportedReports}.
@@ -223,7 +231,7 @@
          return result
  
      ##
-@@ -570,19 +648,21 @@
+@@ -570,19 +647,21 @@
          See L{IDAVResource.authorize}.
          """
          def onError(failure):
@@ -250,7 +258,7 @@
                      response = UnauthorizedResponse(request.credentialFactories,
                                                      request.remoteAddr)
                  else:
-@@ -593,7 +673,7 @@
+@@ -593,7 +672,7 @@
                  # class is supposed to be a FORBIDDEN status code and
                  # "Authorization will not help" according to RFC2616
                  #
@@ -259,7 +267,7 @@
  
              d = self.checkPrivileges(request, privileges, recurse)
              d.addErrback(onErrors)
-@@ -606,16 +686,21 @@
+@@ -606,16 +685,21 @@
  
      def authenticate(self, request):
          def loginSuccess(result):
@@ -285,7 +293,7 @@
  
          authHeader = request.headers.getHeader('authorization')
  
-@@ -631,9 +716,10 @@
+@@ -631,9 +715,10 @@
  
                  # Try to match principals in each principal collection on the resource
                  def gotDetails(details):
@@ -299,7 +307,7 @@
  
                  def login(pcreds):
                      d = request.portal.login(pcreds, None, *request.loginInterfaces)
-@@ -641,13 +727,15 @@
+@@ -641,13 +726,15 @@
  
                      return d
  
@@ -319,7 +327,7 @@
  
      ##
      # ACL
-@@ -656,49 +744,23 @@
+@@ -656,49 +743,23 @@
      def currentPrincipal(self, request):
          """
          @param request: the request being processed.
@@ -378,7 +386,7 @@
          """
          @return: the L{davxml.ACL} element containing the default access control
              list for this resource.
-@@ -710,6 +772,17 @@
+@@ -710,6 +771,17 @@
          #
          return readonlyACL
  
@@ -396,7 +404,7 @@
      def setAccessControlList(self, acl):
          """
          See L{IDAVResource.setAccessControlList}.
-@@ -748,13 +821,16 @@
+@@ -748,13 +820,16 @@
          # 10. Verify that new acl is not in conflict with itself
          # 11. Update acl on the resource
  
@@ -414,7 +422,7 @@
  
          # Need to get list of supported privileges
          supported = []
-@@ -773,10 +849,7 @@
+@@ -773,10 +848,7 @@
          yield supportedPrivs
          supportedPrivs = supportedPrivs.getResult()
          for item in supportedPrivs.children:
@@ -426,7 +434,7 @@
              addSupportedPrivilege(item)
  
          # Steps 1 - 6
-@@ -910,8 +983,7 @@
+@@ -910,8 +982,7 @@
          supportedPrivs = supportedPrivs.getResult()
  
          # Other principals types don't make sense as actors.
@@ -436,7 +444,7 @@
              "Principal is not an actor: %r" % (principal,)
          )
  
-@@ -1019,15 +1091,16 @@
+@@ -1019,15 +1090,16 @@
          def getMyURL():
              url = request.urlForResource(self)
  
@@ -456,7 +464,7 @@
                  "Expected %s response from readDeadProperty() exception, not %s"
                  % (responsecode.NOT_FOUND, e.response.code)
              )
-@@ -1038,9 +1111,9 @@
+@@ -1038,9 +1110,9 @@
  
              if myURL == "/":
                  # If we get to the root without any ACLs, then use the default.
@@ -468,7 +476,7 @@
  
          # Dynamically update privileges for those ace's that are inherited.
          if inheritance:
-@@ -1076,7 +1149,7 @@
+@@ -1076,7 +1148,7 @@
                                  # Adjust ACE for inherit on this resource
                                  children = list(ace.children)
                                  children.remove(TwistedACLInheritable())
@@ -477,7 +485,7 @@
                                  aces.append(davxml.ACE(*children))
              else:
                  aces.extend(inherited_aces)
-@@ -1105,8 +1178,7 @@
+@@ -1105,8 +1177,7 @@
          the child resource loop and supply those to the checkPrivileges on each child.
  
          @param request: the L{IRequest} for the request in progress.
@@ -487,7 +495,7 @@
          """
          
          # Get the parent ACLs with inheritance and preserve the <inheritable> element.
-@@ -1128,21 +1200,9 @@
+@@ -1128,21 +1199,9 @@
                  # Adjust ACE for inherit on this resource
                  children = list(ace.children)
                  children.remove(TwistedACLInheritable())
@@ -511,7 +519,7 @@
  
      inheritedACEsforChildren = deferredGenerator(inheritedACEsforChildren)
  
-@@ -1152,49 +1212,69 @@
+@@ -1152,49 +1211,69 @@
  
          This implementation returns an empty set.
          """
@@ -609,7 +617,7 @@
      def samePrincipal(self, principal1, principal2):
          """
          Check whether the two prinicpals are exactly the same in terms of
-@@ -1219,7 +1299,6 @@
+@@ -1219,7 +1298,6 @@
              return False
                  
      def matchPrincipal(self, principal1, principal2, request):
@@ -617,7 +625,7 @@
          """
          Check whether the principal1 is a principal in the set defined by
          principal2.
-@@ -1244,6 +1323,9 @@
+@@ -1244,6 +1322,9 @@
              if isinstance(principal1, davxml.Unauthenticated):
                  yield False
                  return
@@ -627,7 +635,7 @@
              else:
                  yield True
                  return
-@@ -1260,10 +1342,7 @@
+@@ -1260,10 +1341,7 @@
              yield False
              return
  
@@ -639,7 +647,7 @@
  
          principal2 = waitForDeferred(self.resolvePrincipal(principal2, request))
          yield principal2
-@@ -1271,7 +1350,6 @@
+@@ -1271,7 +1349,6 @@
  
          assert principal2 is not None, "principal2 is None"
  
@@ -647,7 +655,7 @@
          # Compare two HRefs and do group membership test as well
          if principal1 == principal2:
              yield True
-@@ -1289,6 +1367,7 @@
+@@ -1289,6 +1366,7 @@
  
      matchPrincipal = deferredGenerator(matchPrincipal)
  
@@ -655,7 +663,7 @@
      def principalIsGroupMember(self, principal1, principal2, request):
          """
          Check whether one principal is a group member of another.
-@@ -1299,18 +1378,21 @@
+@@ -1299,18 +1377,21 @@
          @return: L{Deferred} with result C{True} if principal1 is a member of principal2, C{False} otherwise
          """
          
@@ -688,7 +696,7 @@
          
      def validPrincipal(self, ace_principal, request):
          """
-@@ -1351,11 +1433,16 @@
+@@ -1351,11 +1432,16 @@
          @return C{True} if C{href_principal} is valid, C{False} otherwise.
  
          This implementation tests for a href element that corresponds to
@@ -708,7 +716,7 @@
          return d
  
      def resolvePrincipal(self, principal, request):
-@@ -1404,8 +1491,7 @@
+@@ -1404,8 +1490,7 @@
              try:
                  principal = principal.getResult()
              except HTTPError, e:
@@ -718,7 +726,7 @@
                      "Expected %s response from readProperty() exception, not %s"
                      % (responsecode.NOT_FOUND, e.response.code)
                  )
-@@ -1432,15 +1518,15 @@
+@@ -1432,15 +1517,15 @@
                  log.err("DAV:self ACE is set on non-principal resource %r" % (self,))
                  yield None
                  return
@@ -737,7 +745,7 @@
              "Not a meta-principal: %r" % (principal,)
          )
  
-@@ -1517,6 +1603,270 @@
+@@ -1517,6 +1602,270 @@
          return None
  
      ##
@@ -1008,7 +1016,7 @@
      # HTTP
      ##
  
-@@ -1525,15 +1875,11 @@
+@@ -1525,15 +1874,11 @@
          #litmus = request.headers.getRawHeaders("x-litmus")
          #if litmus: log.msg("*** Litmus test: %s ***" % (litmus,))
  
@@ -1026,7 +1034,7 @@
  
          def setHeaders(response):
              response = IResponse(response)
-@@ -1567,7 +1913,7 @@
+@@ -1567,7 +1912,7 @@
      def findChildren(self, depth, request, callback, privileges=None, inherited_aces=None):
          return succeed(None)
  
@@ -1035,7 +1043,7 @@
      """
      Resource representing a WebDAV principal.  (RFC 3744, section 2)
      """
-@@ -1577,7 +1923,7 @@
+@@ -1577,7 +1922,7 @@
      # WebDAV
      ##
  
@@ -1044,7 +1052,7 @@
          (dav_namespace, "alternate-URI-set"),
          (dav_namespace, "principal-URL"    ),
          (dav_namespace, "group-member-set" ),
-@@ -1585,14 +1931,11 @@
+@@ -1585,14 +1930,11 @@
      )
  
      def davComplianceClasses(self):
@@ -1060,7 +1068,7 @@
      def readProperty(self, property, request):
          def defer():
              if type(property) is tuple:
-@@ -1610,10 +1953,20 @@
+@@ -1610,10 +1952,20 @@
                      return davxml.PrincipalURL(davxml.HRef(self.principalURL()))
  
                  if name == "group-member-set":
@@ -1083,7 +1091,7 @@
  
                  if name == "resourcetype":
                      if self.isCollection():
-@@ -1655,7 +2008,7 @@
+@@ -1655,7 +2007,7 @@
          principals.  Subclasses should override this method to provide member
          URLs for this resource if appropriate.
          """
@@ -1092,7 +1100,7 @@
  
      def groupMemberships(self):
          """
-@@ -1666,6 +2019,7 @@
+@@ -1666,6 +2018,7 @@
          """
          unimplemented(self)
  
@@ -1100,7 +1108,7 @@
      def principalMatch(self, href):
          """
          Check whether the supplied principal matches this principal or is a
-@@ -1675,10 +2029,33 @@
+@@ -1675,10 +2028,33 @@
          """
          uri = str(href)
          if self.principalURL() == uri:
@@ -1136,7 +1144,7 @@
  class AccessDeniedError(Exception):
      def __init__(self, errors):
          """ 
-@@ -1718,6 +2095,37 @@
+@@ -1718,6 +2094,37 @@
  davxml.registerElement(TwistedACLInheritable)
  davxml.ACE.allowed_children[(twisted_dav_namespace, "inheritable")] = (0, 1)
  

Modified: CalendarServer/trunk/twistedcaldav/method/put_common.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/method/put_common.py	2008-10-18 02:09:15 UTC (rev 3188)
+++ CalendarServer/trunk/twistedcaldav/method/put_common.py	2008-10-19 01:11:29 UTC (rev 3189)
@@ -38,6 +38,7 @@
 from twisted.web2.dav.util import joinURL, parentForURL
 from twisted.web2.http import HTTPError
 from twisted.web2.http import StatusResponse
+from twisted.web2.http_headers import generateContentType
 from twisted.web2.iweb import IResponse
 from twisted.web2.stream import MemoryStream
 
@@ -614,8 +615,6 @@
                 responsecode.FORBIDDEN,
                     NumberOfRecurrencesWithinLimits(PCDATAElement(str(ex.max_allowed)))
                 ))
-
-            self.source.writeDeadProperty(davxml.GETContentType.fromString("text/calendar"))
             return None
 
     def doDestinationIndex(self, caltoindex):
@@ -643,7 +642,11 @@
             log.err("Cannot index calendar resource: %s" % (ex,))
             raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "valid-calendar-data")))
 
-        self.destination.writeDeadProperty(davxml.GETContentType.fromString("text/calendar"))
+        content_type = self.request.headers.getHeader("content-type")
+        if content_type is not None:
+            self.destination.writeDeadProperty(davxml.GETContentType.fromString(generateContentType(content_type)))
+        else:
+            self.destination.writeDeadProperty(davxml.GETContentType.fromString("text/calendar"))
         return None
 
     def doRemoveDestinationIndex(self):
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20081018/bcd347e5/attachment-0001.html 


More information about the calendarserver-changes mailing list