Merge branch 'master' of github.com:Kozea/radicale
This commit is contained in:
commit
ac687c6179
@ -6,10 +6,9 @@ python:
|
|||||||
- 3.5
|
- 3.5
|
||||||
|
|
||||||
install:
|
install:
|
||||||
- pip install -e .
|
- pip install tox
|
||||||
- pip install tox flake8
|
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- tox -r -e py
|
- tox -e py
|
||||||
|
|
||||||
sudo: false
|
sudo: false
|
||||||
|
@ -33,6 +33,7 @@ import socket
|
|||||||
import ssl
|
import ssl
|
||||||
import wsgiref.simple_server
|
import wsgiref.simple_server
|
||||||
import re
|
import re
|
||||||
|
import zlib
|
||||||
from http import client
|
from http import client
|
||||||
from urllib.parse import unquote, urlparse
|
from urllib.parse import unquote, urlparse
|
||||||
|
|
||||||
@ -314,6 +315,13 @@ class Application:
|
|||||||
if answer:
|
if answer:
|
||||||
self.logger.debug("Response content:\n%s" % answer, environ)
|
self.logger.debug("Response content:\n%s" % answer, environ)
|
||||||
answer = answer.encode(self.encoding)
|
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))
|
headers["Content-Length"] = str(len(answer))
|
||||||
|
|
||||||
if self.configuration.has_section("headers"):
|
if self.configuration.has_section("headers"):
|
||||||
|
@ -173,7 +173,7 @@ def run():
|
|||||||
if not configuration.getboolean("server", "dns_lookup"):
|
if not configuration.getboolean("server", "dns_lookup"):
|
||||||
RequestHandler.address_string = lambda self: self.client_address[0]
|
RequestHandler.address_string = lambda self: self.client_address[0]
|
||||||
|
|
||||||
shutdown_program = [False]
|
shutdown_program = False
|
||||||
|
|
||||||
for host in configuration.get("server", "hosts").split(","):
|
for host in configuration.get("server", "hosts").split(","):
|
||||||
address, port = host.strip().rsplit(":", 1)
|
address, port = host.strip().rsplit(":", 1)
|
||||||
@ -198,11 +198,12 @@ def run():
|
|||||||
# SIGTERM and SIGINT (aka KeyboardInterrupt) should just mark this for
|
# SIGTERM and SIGINT (aka KeyboardInterrupt) should just mark this for
|
||||||
# shutdown
|
# shutdown
|
||||||
def shutdown(*args):
|
def shutdown(*args):
|
||||||
if shutdown_program[0]:
|
nonlocal shutdown_program
|
||||||
|
if shutdown_program:
|
||||||
# Ignore following signals
|
# Ignore following signals
|
||||||
return
|
return
|
||||||
logger.info("Stopping Radicale")
|
logger.info("Stopping Radicale")
|
||||||
shutdown_program[0] = True
|
shutdown_program = True
|
||||||
if shutdown_program_socket_in:
|
if shutdown_program_socket_in:
|
||||||
shutdown_program_socket_in.sendall(b"goodbye")
|
shutdown_program_socket_in.sendall(b"goodbye")
|
||||||
signal.signal(signal.SIGTERM, shutdown)
|
signal.signal(signal.SIGTERM, shutdown)
|
||||||
@ -218,7 +219,7 @@ def run():
|
|||||||
# Fallback to busy waiting
|
# Fallback to busy waiting
|
||||||
select_timeout = 1.0
|
select_timeout = 1.0
|
||||||
logger.debug("Radicale server ready")
|
logger.debug("Radicale server ready")
|
||||||
while not shutdown_program[0]:
|
while not shutdown_program:
|
||||||
try:
|
try:
|
||||||
rlist, _, xlist = select.select(
|
rlist, _, xlist = select.select(
|
||||||
sockets, [], sockets, select_timeout)
|
sockets, [], sockets, select_timeout)
|
||||||
|
@ -97,7 +97,6 @@ def path_to_filesystem(root, *paths):
|
|||||||
Conversion is done in a secure manner, or raises ``ValueError``.
|
Conversion is done in a secure manner, or raises ``ValueError``.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
root = sanitize_path(root)
|
|
||||||
paths = [sanitize_path(path).strip("/") for path in paths]
|
paths = [sanitize_path(path).strip("/") for path in paths]
|
||||||
safe_path = root
|
safe_path = root
|
||||||
for path in paths:
|
for path in paths:
|
||||||
@ -303,7 +302,7 @@ class Collection(BaseCollection):
|
|||||||
_, directories, _ = next(os.walk(collection._filesystem_path))
|
_, directories, _ = next(os.walk(collection._filesystem_path))
|
||||||
for sub_path in directories:
|
for sub_path in directories:
|
||||||
full_path = os.path.join(collection._filesystem_path, sub_path)
|
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))
|
yield cls(posixpath.join(path, sub_path))
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@ -133,6 +133,9 @@ def _comp_match(item, filter_, scope="collection"):
|
|||||||
for component in item.components():
|
for component in item.components():
|
||||||
if component.name in ("VTODO", "VEVENT", "VJOURNAL"):
|
if component.name in ("VTODO", "VEVENT", "VJOURNAL"):
|
||||||
tag = component.name
|
tag = component.name
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
return False
|
||||||
if filter_length == 0:
|
if filter_length == 0:
|
||||||
# Point #1 of rfc4791-9.7.1
|
# Point #1 of rfc4791-9.7.1
|
||||||
return filter_.get("name") == tag
|
return filter_.get("name") == tag
|
||||||
|
Loading…
x
Reference in New Issue
Block a user