Revision: 1502 http://trac.macosforge.org/projects/calendarserver/changeset/1502 Author: dreid@apple.com Date: 2007-04-27 15:20:45 -0700 (Fri, 27 Apr 2007) Log Message: ----------- Add support for and a config option for control of GZip Content-Encoding (see RFC 2616 Section 3.5) Modified Paths: -------------- CalendarServer/trunk/twistedcaldav/config.py CalendarServer/trunk/twistedcaldav/root.py Modified: CalendarServer/trunk/twistedcaldav/config.py =================================================================== --- CalendarServer/trunk/twistedcaldav/config.py 2007-04-27 22:19:52 UTC (rev 1501) +++ CalendarServer/trunk/twistedcaldav/config.py 2007-04-27 22:20:45 UTC (rev 1502) @@ -172,10 +172,13 @@ # A unix socket used for communication between the child and master # processes. "ControlSocket": "/var/run/caldavd.sock", - + # A secret key (SHA-1 hash of random string) that is used for internal # crypto operations and shared by multiple server processes "SharedSecret": "", + + # Support for the gzip Content-Encoding as specified in RFC2616 Section 3.5 + "GZipEncoding": True, } class Config (object): Modified: CalendarServer/trunk/twistedcaldav/root.py =================================================================== --- CalendarServer/trunk/twistedcaldav/root.py 2007-04-27 22:19:52 UTC (rev 1501) +++ CalendarServer/trunk/twistedcaldav/root.py 2007-04-27 22:20:45 UTC (rev 1502) @@ -34,6 +34,7 @@ class RootResource(DAVFile): """ A special root resource that contains support checking SACLs + as well as adding responseFilters. """ useSacls = False @@ -50,6 +51,12 @@ "config.EnableSACLs is True, SACLs will not be" "turned on.")) + self.contentFilters = [] + + if config.GZipEncoding: + from twisted.web2.filter import gzip + self.contentFilters.append((gzip.gzipfilter, True)) + def checkSacl(self, request): """ Check SACLs against the current request @@ -92,6 +99,9 @@ return d def locateChild(self, request, segments): + for filter in self.contentFilters: + request.addResponseFilter(filter[0], atEnd=filter[1]) + if self.useSacls: d = self.checkSacl(request) d.addCallback(lambda _: super(RootResource, self