From 4b87cb91814c344d5a33d4a663b8e47d3c5536e0 Mon Sep 17 00:00:00 2001 From: Guillaume Ayoub Date: Thu, 25 Aug 2011 14:28:37 +0200 Subject: [PATCH] Avoid the redirection loop (fixes #571) --- radicale/__init__.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/radicale/__init__.py b/radicale/__init__.py index 2233946..c226c31 100644 --- a/radicale/__init__.py +++ b/radicale/__init__.py @@ -223,12 +223,18 @@ class Application(object): status, headers, answer = function( environ, calendars, content, user) elif user and last_allowed is None: - # Good user and no calendars found, redirect user to home + # Good user and no calendars found location = "/%s/" % str(quote(user)) - log.LOGGER.info("redirecting to %s" % location) - status = client.FOUND - headers = {"Location": location} - answer = "Redirecting to %s" % location + if location == environ["PATH_INFO"]: + # We already have redirected the client + status, headers, answer = function( + environ, calendars, content, user) + else: + # Redirect the client + log.LOGGER.info("redirecting to %s" % location) + status = client.FOUND + headers = {"Location": location} + answer = "Redirecting to %s" % location else: # Unknown or unauthorized user status = client.UNAUTHORIZED