Guillaume Ayoub 15 лет назад
Родитель
Сommit
77ab37c49c
1 измененных файлов с 6 добавлено и 6 удалено
  1. 6 6
      radicale/__init__.py

+ 6 - 6
radicale/__init__.py

@@ -186,13 +186,13 @@ class Application(object):
 
         # Set content length
         if answer:
-            # Decode the answer for logging purposes on Python 3
-            log_answer = answer
-            if not isinstance(log_answer, str):
-                log_answer = log_answer.decode(
-                    config.get("encoding", "request"))
+            if isinstance(answer, str):
+                log_answer = answer
+            else:
+                # Decode the answer for logging purposes on Python 3
+                log_answer = answer.decode(config.get("encoding", "request"))
             log.LOGGER.debug("Response content:\n%s" % log_answer)
-            headers["Content-Length"] = "%i" % len(answer)
+            headers["Content-Length"] = str(len(answer))
 
         # Start response
         status = "%i %s" % (status, client.responses.get(status, ""))