From 5704b5021b42f499a89cd072c4d92be90362e49d Mon Sep 17 00:00:00 2001 From: Unrud Date: Wed, 31 May 2017 12:01:35 +0200 Subject: [PATCH] PATH_INFO might not exist if it's empty --- radicale/__init__.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/radicale/__init__.py b/radicale/__init__.py index 5aac750..0ff1bb4 100644 --- a/radicale/__init__.py +++ b/radicale/__init__.py @@ -334,8 +334,8 @@ class Application: status, client.responses.get(status, "Unknown")) self.logger.info( "%s answer status for %r%s in %.3f seconds: %s", - environ["REQUEST_METHOD"], environ["PATH_INFO"], depthinfo, - (time_end - time_begin).total_seconds(), status) + environ["REQUEST_METHOD"], environ.get("PATH_INFO", ""), + depthinfo, (time_end - time_begin).total_seconds(), status) # Return response content return status, list(headers.items()), [answer] if answer else [] @@ -372,6 +372,7 @@ class Application: environ.get("SCRIPT_NAME", "")).rstrip("/") self.logger.debug("Sanitized script name: %r", environ["SCRIPT_NAME"]) base_prefix = environ["SCRIPT_NAME"] + environ["PATH_INFO"] = environ.get("PATH_INFO", "") # Sanitize request URI (a WSGI server indicates with an empty path, # that the URL targets the application root without a trailing slash) if environ["PATH_INFO"]: