diff --git a/.travis.yml b/.travis.yml index 155808f..3252b1b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,10 +6,9 @@ python: - 3.5 install: - - pip install -e . - - pip install tox flake8 + - pip install tox script: - - tox -r -e py + - tox -e py sudo: false diff --git a/radicale/__init__.py b/radicale/__init__.py index 35ab75d..5251bfc 100644 --- a/radicale/__init__.py +++ b/radicale/__init__.py @@ -33,6 +33,7 @@ import socket import ssl import wsgiref.simple_server import re +import zlib from http import client from urllib.parse import unquote, urlparse @@ -314,6 +315,13 @@ class Application: if answer: self.logger.debug("Response content:\n%s" % answer, environ) answer = answer.encode(self.encoding) + accept_encoding = [ + encoding.strip() for encoding in + environ.get("HTTP_ACCEPT_ENCODING", "").split(",") + if encoding.strip()] + if "deflate" in accept_encoding: + answer = zlib.compress(answer) + headers["Content-Encoding"] = "deflate" headers["Content-Length"] = str(len(answer)) if self.configuration.has_section("headers"): diff --git a/radicale/__main__.py b/radicale/__main__.py index 73f7f2b..9672214 100644 --- a/radicale/__main__.py +++ b/radicale/__main__.py @@ -173,7 +173,7 @@ def run(): if not configuration.getboolean("server", "dns_lookup"): RequestHandler.address_string = lambda self: self.client_address[0] - shutdown_program = [False] + shutdown_program = False for host in configuration.get("server", "hosts").split(","): address, port = host.strip().rsplit(":", 1) @@ -198,11 +198,12 @@ def run(): # SIGTERM and SIGINT (aka KeyboardInterrupt) should just mark this for # shutdown def shutdown(*args): - if shutdown_program[0]: + nonlocal shutdown_program + if shutdown_program: # Ignore following signals return logger.info("Stopping Radicale") - shutdown_program[0] = True + shutdown_program = True if shutdown_program_socket_in: shutdown_program_socket_in.sendall(b"goodbye") signal.signal(signal.SIGTERM, shutdown) @@ -218,7 +219,7 @@ def run(): # Fallback to busy waiting select_timeout = 1.0 logger.debug("Radicale server ready") - while not shutdown_program[0]: + while not shutdown_program: try: rlist, _, xlist = select.select( sockets, [], sockets, select_timeout) diff --git a/radicale/storage.py b/radicale/storage.py index 982026f..a6f744f 100644 --- a/radicale/storage.py +++ b/radicale/storage.py @@ -97,7 +97,6 @@ def path_to_filesystem(root, *paths): Conversion is done in a secure manner, or raises ``ValueError``. """ - root = sanitize_path(root) paths = [sanitize_path(path).strip("/") for path in paths] safe_path = root for path in paths: @@ -303,7 +302,7 @@ class Collection(BaseCollection): _, directories, _ = next(os.walk(collection._filesystem_path)) for sub_path in directories: full_path = os.path.join(collection._filesystem_path, sub_path) - if os.path.exists(path_to_filesystem(full_path)): + if os.path.exists(full_path): yield cls(posixpath.join(path, sub_path)) @classmethod diff --git a/radicale/xmlutils.py b/radicale/xmlutils.py index bd07b2e..8ce63c6 100644 --- a/radicale/xmlutils.py +++ b/radicale/xmlutils.py @@ -133,6 +133,9 @@ def _comp_match(item, filter_, scope="collection"): for component in item.components(): if component.name in ("VTODO", "VEVENT", "VJOURNAL"): tag = component.name + break + else: + return False if filter_length == 0: # Point #1 of rfc4791-9.7.1 return filter_.get("name") == tag diff --git a/tox.ini b/tox.ini index 02e5637..fed01a0 100644 --- a/tox.ini +++ b/tox.ini @@ -1,12 +1,11 @@ [tox] envlist = py33, py34, py35 -[base] +[testenv] deps = flake8 pytest -[testenv] commands = flake8 py.test