From ca056dea9faefba39ff4bbfc5cc4dbe942cca8ba Mon Sep 17 00:00:00 2001 From: Guillaume Ayoub Date: Thu, 12 May 2016 18:55:03 +0200 Subject: [PATCH] Don't return 404 for GET requests on collections --- radicale/__init__.py | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/radicale/__init__.py b/radicale/__init__.py index 98554fe..eab85a8 100644 --- a/radicale/__init__.py +++ b/radicale/__init__.py @@ -258,9 +258,7 @@ class Application: except KeyError: status = client.UNAUTHORIZED realm = self.configuration.get("server", "realm") - headers = { - "WWW-Authenticate": - "Basic realm=\"%s\"" % realm} + headers = {"WWW-Authenticate": "Basic realm=\"%s\"" % realm} self.logger.info( "Refused /.well-known/ redirection to anonymous user") else: @@ -379,23 +377,22 @@ class Application: # Get collection item item = collection.get(item_name) if item: - answer_text = item.serialize() + answer = item.serialize() etag = item.etag else: return client.NOT_FOUND, {}, None else: # Get whole collection - answer_text = collection.serialize() - if not answer_text: - self.logger.debug("Collection at %s unknown" % environ["PATH_INFO"]) - return client.NOT_FOUND, {}, None + answer = collection.serialize() etag = collection.etag - headers = { - "Content-Type": storage.MIMETYPES[collection.get_meta("tag")], - "Last-Modified": collection.last_modified, - "ETag": etag} - answer = answer_text + if answer: + headers = { + "Content-Type": storage.MIMETYPES[collection.get_meta("tag")], + "Last-Modified": collection.last_modified, + "ETag": etag} + else: + headers = {} return client.OK, headers, answer def do_HEAD(self, environ, read_collections, write_collections, content,