1
0
Fork 0
mirror of https://github.com/Kozea/Radicale.git synced 2025-09-15 20:36:55 +00:00

Add section for internal configuration

This commit is contained in:
Unrud 2018-08-18 12:56:38 +02:00
parent 59f7104dce
commit 4282ea46e4
3 changed files with 22 additions and 11 deletions

View file

@ -93,7 +93,7 @@ DAV_HEADERS = "1, 2, 3, calendar-access, addressbook, extended-mkcol"
class Application:
"""WSGI application managing collections."""
def __init__(self, configuration, internal_server=False):
def __init__(self, configuration):
"""Initialize application."""
super().__init__()
self.configuration = configuration
@ -102,7 +102,6 @@ class Application:
self.Rights = rights.load(configuration)
self.Web = web.load(configuration)
self.encoding = configuration.get("encoding", "request")
self.internal_server = internal_server
def headers_log(self, environ):
"""Sanitize headers for logging."""
@ -333,14 +332,15 @@ class Application:
logger.warning("Access to principal path %r denied by "
"rights backend", principal_path)
# Verify content length
content_length = int(environ.get("CONTENT_LENGTH") or 0)
if self.internal_server and content_length:
max_content_length = self.configuration.getint(
"server", "max_content_length")
if max_content_length and content_length > max_content_length:
logger.info("Request body too large: %d", content_length)
return response(*REQUEST_ENTITY_TOO_LARGE)
if self.configuration.getboolean("internal", "internal_server"):
# Verify content length
content_length = int(environ.get("CONTENT_LENGTH") or 0)
if content_length:
max_content_length = self.configuration.getint(
"server", "max_content_length")
if max_content_length and content_length > max_content_length:
logger.info("Request body too large: %d", content_length)
return response(*REQUEST_ENTITY_TOO_LARGE)
if not login or user:
status, headers, answer = function(