Revision
829
Author
wsanchez@apple.com
Date
2006-12-14 17:04:48 -0800 (Thu, 14 Dec 2006)

Log Message

Send dirlist if HTML agent

Modified Paths

Diff

Modified: CalendarServer/trunk/twistedcaldav/resource.py (828 => 829)


--- CalendarServer/trunk/twistedcaldav/resource.py	2006-12-15 00:01:31 UTC (rev 828)
+++ CalendarServer/trunk/twistedcaldav/resource.py	2006-12-15 01:04:48 UTC (rev 829)
@@ -83,7 +83,17 @@
     ##
 
     def render(self, request):
-        if self.isPseudoCalendarCollection():
+        # Send listing instead of iCalendar data to HTML agents
+        # This is mostly useful for debugging...
+        # FIXME: Add a self-link to the dirlist with a query string so
+        #     users can still download the actual iCalendar data?
+        agent = request.headers.getHeader("user-agent")
+        if agent.startswith("Mozilla/") and agent.find("Gecko") != -1:
+            html_agent = True
+        else:
+            html_agent = False
+
+        if not html_agent and self.isPseudoCalendarCollection():
             # Render a monolithic iCalendar file
             if request.uri[-1] != "/":
                 # Redirect to include trailing '/' in URI