"""Return a Resource object corresponding to the path (this is used for
everything that is not a collection, like Principal and HomeSet objects)"""
+ if path in ("/.well-known/carddav", "/.well-known/caldav"):
+ return principal.WellKnownDav()
+
try:
left, right = config.get('server', 'user_principal').split('%(user)s')
except ValueError:
if is_get:
answer_text = self._collection.text
etag = self._collection.etag
+ elif self._resource:
+ self._resource.do_get_head(self, context, is_get)
+ return
else:
self.send_calypso_response(client.NOT_FOUND, 0)
self.end_headers()
responded with to a propfind of a given depth"""
return [self]
+ def do_get_head(self, request, context, is_get):
+ """Handle an incoming GET or HEAD request. See
+ CollectionHTTPHandler.do_get_head for what this usually should do."""
+ request.send_calypso_response(404, 0)
+ request.end_headers()
+
urlpath = None # this should be present ... implement as abstract property?
+class WellKnownDav(Resource):
+ def has_right(self, user):
+ return True
+
+ def do_get_head(self, request, context, is_get):
+ """According to RFC6764, redirect to a context path (from where
+ current-user-principal can be discovered)"""
+ request.send_calypso_response(303, 0)
+ request.send_header("Location", config.get("server", "base_prefix"))
+ request.end_headers()
+
class Principal(Resource):
def __init__(self, username):
self.username = username