Set charsets in headers
This commit is contained in:
parent
c459d32a19
commit
e55d75ce46
@ -51,28 +51,28 @@ from . import auth, rights, storage, xmlutils
|
|||||||
VERSION = "2.0.0rc0"
|
VERSION = "2.0.0rc0"
|
||||||
|
|
||||||
NOT_ALLOWED = (
|
NOT_ALLOWED = (
|
||||||
client.FORBIDDEN, (("Content-type", "text/plain"),),
|
client.FORBIDDEN, (("Content-Type", "text/plain"),),
|
||||||
"Access to the requested resource forbidden.")
|
"Access to the requested resource forbidden.")
|
||||||
NOT_FOUND = (
|
NOT_FOUND = (
|
||||||
client.NOT_FOUND, (("Content-type", "text/plain"),),
|
client.NOT_FOUND, (("Content-Type", "text/plain"),),
|
||||||
"The requested resource could not be found.")
|
"The requested resource could not be found.")
|
||||||
WEBDAV_PRECONDITION_FAILED = (
|
WEBDAV_PRECONDITION_FAILED = (
|
||||||
client.CONFLICT, (("Content-type", "text/plain"),),
|
client.CONFLICT, (("Content-Type", "text/plain"),),
|
||||||
"WebDAV precondition failed.")
|
"WebDAV precondition failed.")
|
||||||
PRECONDITION_FAILED = (
|
PRECONDITION_FAILED = (
|
||||||
client.PRECONDITION_FAILED,
|
client.PRECONDITION_FAILED,
|
||||||
(("Content-type", "text/plain"),), "Precondition failed.")
|
(("Content-Type", "text/plain"),), "Precondition failed.")
|
||||||
REQUEST_TIMEOUT = (
|
REQUEST_TIMEOUT = (
|
||||||
client.REQUEST_TIMEOUT, (("Content-type", "text/plain"),),
|
client.REQUEST_TIMEOUT, (("Content-Type", "text/plain"),),
|
||||||
"Connection timed out.")
|
"Connection timed out.")
|
||||||
REQUEST_ENTITY_TOO_LARGE = (
|
REQUEST_ENTITY_TOO_LARGE = (
|
||||||
client.REQUEST_ENTITY_TOO_LARGE, (("Content-type", "text/plain"),),
|
client.REQUEST_ENTITY_TOO_LARGE, (("Content-Type", "text/plain"),),
|
||||||
"Request body too large.")
|
"Request body too large.")
|
||||||
REMOTE_DESTINATION = (
|
REMOTE_DESTINATION = (
|
||||||
client.BAD_GATEWAY, (("Content-type", "text/plain"),),
|
client.BAD_GATEWAY, (("Content-Type", "text/plain"),),
|
||||||
"Remote destination not supported.")
|
"Remote destination not supported.")
|
||||||
DIRECTORY_LISTING = (
|
DIRECTORY_LISTING = (
|
||||||
client.FORBIDDEN, (("Content-type", "text/plain"),),
|
client.FORBIDDEN, (("Content-Type", "text/plain"),),
|
||||||
"Directory listings are not supported.")
|
"Directory listings are not supported.")
|
||||||
|
|
||||||
DAV_HEADERS = "1, 2, 3, calendar-access, addressbook, extended-mkcol"
|
DAV_HEADERS = "1, 2, 3, calendar-access, addressbook, extended-mkcol"
|
||||||
@ -288,6 +288,7 @@ class Application:
|
|||||||
headers["Content-Encoding"] = "gzip"
|
headers["Content-Encoding"] = "gzip"
|
||||||
|
|
||||||
headers["Content-Length"] = str(len(answer))
|
headers["Content-Length"] = str(len(answer))
|
||||||
|
headers["Content-Type"] += "; charset=%s" % self.encoding
|
||||||
|
|
||||||
# Add extra headers set in configuration
|
# Add extra headers set in configuration
|
||||||
if self.configuration.has_section("headers"):
|
if self.configuration.has_section("headers"):
|
||||||
@ -441,13 +442,13 @@ class Application:
|
|||||||
answer = xmlutils.delete(path, item)
|
answer = xmlutils.delete(path, item)
|
||||||
else:
|
else:
|
||||||
answer = xmlutils.delete(path, item.collection, item.href)
|
answer = xmlutils.delete(path, item.collection, item.href)
|
||||||
return client.OK, {}, answer
|
return client.OK, {"Content-Type": "text/xml"}, answer
|
||||||
|
|
||||||
def do_GET(self, environ, path, user):
|
def do_GET(self, environ, path, user):
|
||||||
"""Manage GET request."""
|
"""Manage GET request."""
|
||||||
# Display a "Radicale works!" message if the root URL is requested
|
# Display a "Radicale works!" message if the root URL is requested
|
||||||
if not path.strip("/"):
|
if not path.strip("/"):
|
||||||
return client.OK, {"Content-type": "text/plain"}, "Radicale works!"
|
return client.OK, {"Content-Type": "text/plain"}, "Radicale works!"
|
||||||
if not self._access(user, path, "r"):
|
if not self._access(user, path, "r"):
|
||||||
return NOT_ALLOWED
|
return NOT_ALLOWED
|
||||||
with self.Collection.acquire_lock("r", user):
|
with self.Collection.acquire_lock("r", user):
|
||||||
@ -458,7 +459,8 @@ class Application:
|
|||||||
return NOT_FOUND
|
return NOT_FOUND
|
||||||
if isinstance(item, self.Collection):
|
if isinstance(item, self.Collection):
|
||||||
collection = item
|
collection = item
|
||||||
if collection.get_meta("tag") not in ("VADDRESSBOOK", "VCALENDAR"):
|
if collection.get_meta("tag") not in (
|
||||||
|
"VADDRESSBOOK", "VCALENDAR"):
|
||||||
return DIRECTORY_LISTING
|
return DIRECTORY_LISTING
|
||||||
else:
|
else:
|
||||||
collection = item.collection
|
collection = item.collection
|
||||||
|
Loading…
Reference in New Issue
Block a user