__init__.py 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636
  1. # This file is part of Radicale Server - Calendar Server
  2. # Copyright © 2008 Nicolas Kandel
  3. # Copyright © 2008 Pascal Halter
  4. # Copyright © 2008-2016 Guillaume Ayoub
  5. #
  6. # This library is free software: you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License as published by
  8. # the Free Software Foundation, either version 3 of the License, or
  9. # (at your option) any later version.
  10. #
  11. # This library is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with Radicale. If not, see <http://www.gnu.org/licenses/>.
  18. """
  19. Radicale Server module.
  20. This module offers a WSGI application class.
  21. To use this module, you should take a look at the file ``radicale.py`` that
  22. should have been included in this package.
  23. """
  24. import base64
  25. import contextlib
  26. import io
  27. import itertools
  28. import os
  29. import posixpath
  30. import pprint
  31. import socket
  32. import socketserver
  33. import ssl
  34. import threading
  35. import urllib
  36. import wsgiref.simple_server
  37. import zlib
  38. from contextlib import contextmanager
  39. from http import client
  40. from urllib.parse import unquote, urlparse
  41. import vobject
  42. from . import auth, rights, storage, xmlutils
  43. VERSION = "2.0.0rc0"
  44. NOT_ALLOWED = (client.FORBIDDEN, {}, None)
  45. DAV_HEADERS = "1, 2, 3, calendar-access, addressbook, extended-mkcol"
  46. class HTTPServer(wsgiref.simple_server.WSGIServer):
  47. """HTTP server."""
  48. # These class attributes must be set before creating instance
  49. client_timeout = None
  50. max_connections = None
  51. def __init__(self, address, handler, bind_and_activate=True):
  52. """Create server."""
  53. ipv6 = ":" in address[0]
  54. if ipv6:
  55. self.address_family = socket.AF_INET6
  56. # Do not bind and activate, as we might change socket options
  57. super().__init__(address, handler, False)
  58. if ipv6:
  59. # Only allow IPv6 connections to the IPv6 socket
  60. self.socket.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_V6ONLY, 1)
  61. if bind_and_activate:
  62. self.server_bind()
  63. self.server_activate()
  64. if self.max_connections:
  65. self.connections_guard = threading.BoundedSemaphore(
  66. self.max_connections)
  67. else:
  68. # use dummy context manager
  69. self.connections_guard = contextlib.suppress()
  70. def get_request(self):
  71. # Set timeout for client
  72. _socket, address = super().get_request()
  73. if self.client_timeout:
  74. _socket.settimeout(self.client_timeout)
  75. return _socket, address
  76. class HTTPSServer(HTTPServer):
  77. """HTTPS server."""
  78. # These class attributes must be set before creating instance
  79. certificate = None
  80. key = None
  81. protocol = None
  82. ciphers = None
  83. def __init__(self, address, handler):
  84. """Create server by wrapping HTTP socket in an SSL socket."""
  85. super().__init__(address, handler, bind_and_activate=False)
  86. self.socket = ssl.wrap_socket(
  87. self.socket, self.key, self.certificate, server_side=True,
  88. ssl_version=self.protocol, ciphers=self.ciphers)
  89. self.server_bind()
  90. self.server_activate()
  91. class ThreadedHTTPServer(socketserver.ThreadingMixIn, HTTPServer):
  92. def process_request_thread(self, request, client_address):
  93. with self.connections_guard:
  94. return super().process_request_thread(request, client_address)
  95. class ThreadedHTTPSServer(socketserver.ThreadingMixIn, HTTPSServer):
  96. def process_request_thread(self, request, client_address):
  97. with self.connections_guard:
  98. return super().process_request_thread(request, client_address)
  99. class RequestHandler(wsgiref.simple_server.WSGIRequestHandler):
  100. """HTTP requests handler."""
  101. # These class attributes must be set before creating instance
  102. logger = None
  103. def __init__(self, *args, **kwargs):
  104. # Store exception for logging
  105. self.error_stream = io.StringIO()
  106. super().__init__(*args, **kwargs)
  107. def get_stderr(self):
  108. return self.error_stream
  109. def log_message(self, *args, **kwargs):
  110. """Disable inner logging management."""
  111. def get_environ(self):
  112. env = super().get_environ()
  113. # Parent class only tries latin1 encoding
  114. env["PATH_INFO"] = urllib.parse.unquote(self.path.split("?", 1)[0])
  115. return env
  116. def handle(self):
  117. super().handle()
  118. # Log exception
  119. error = self.error_stream.getvalue().strip("\n")
  120. if error:
  121. self.logger.error(
  122. "An exception occurred during request:\n%s" % error)
  123. class Application:
  124. """WSGI application managing collections."""
  125. def __init__(self, configuration, logger):
  126. """Initialize application."""
  127. super().__init__()
  128. self.configuration = configuration
  129. self.logger = logger
  130. self.is_authenticated = auth.load(configuration, logger)
  131. self.Collection = storage.load(configuration, logger)
  132. self.authorized = rights.load(configuration, logger)
  133. self.encoding = configuration.get("encoding", "request")
  134. def headers_log(self, environ):
  135. """Sanitize headers for logging."""
  136. request_environ = dict(environ)
  137. # Remove environment variables
  138. if not self.configuration.getboolean("logging", "full_environment"):
  139. for shell_variable in os.environ:
  140. request_environ.pop(shell_variable, None)
  141. # Mask passwords
  142. mask_passwords = self.configuration.getboolean(
  143. "logging", "mask_passwords")
  144. authorization = request_environ.get(
  145. "HTTP_AUTHORIZATION", "").startswith("Basic")
  146. if mask_passwords and authorization:
  147. request_environ["HTTP_AUTHORIZATION"] = "Basic **masked**"
  148. return request_environ
  149. def decode(self, text, environ):
  150. """Try to magically decode ``text`` according to given ``environ``."""
  151. # List of charsets to try
  152. charsets = []
  153. # First append content charset given in the request
  154. content_type = environ.get("CONTENT_TYPE")
  155. if content_type and "charset=" in content_type:
  156. charsets.append(
  157. content_type.split("charset=")[1].split(";")[0].strip())
  158. # Then append default Radicale charset
  159. charsets.append(self.encoding)
  160. # Then append various fallbacks
  161. charsets.append("utf-8")
  162. charsets.append("iso8859-1")
  163. # Try to decode
  164. for charset in charsets:
  165. try:
  166. return text.decode(charset)
  167. except UnicodeDecodeError:
  168. pass
  169. raise UnicodeDecodeError
  170. def collect_allowed_items(self, items, user):
  171. """Get items from request that user is allowed to access."""
  172. read_allowed_items = []
  173. write_allowed_items = []
  174. for item in items:
  175. if isinstance(item, self.Collection):
  176. path = item.path
  177. else:
  178. path = item.collection.path
  179. if self.authorized(user, path, "r"):
  180. self.logger.debug(
  181. "%s has read access to collection %s",
  182. user or "Anonymous", path or "/")
  183. read_allowed_items.append(item)
  184. else:
  185. self.logger.debug(
  186. "%s has NO read access to collection %s",
  187. user or "Anonymous", path or "/")
  188. if self.authorized(user, path, "w"):
  189. self.logger.debug(
  190. "%s has write access to collection %s",
  191. user or "Anonymous", path or "/")
  192. write_allowed_items.append(item)
  193. else:
  194. self.logger.debug(
  195. "%s has NO write access to collection %s",
  196. user or "Anonymous", path or "/")
  197. return read_allowed_items, write_allowed_items
  198. def __call__(self, environ, start_response):
  199. """Manage a request."""
  200. def response(status, headers={}, answer=None):
  201. # Start response
  202. status = "%i %s" % (
  203. status, client.responses.get(status, "Unknown"))
  204. self.logger.debug("Answer status: %s", status)
  205. start_response(status, list(headers.items()))
  206. # Return response content
  207. return [answer] if answer else []
  208. self.logger.debug("\n") # Add empty lines between requests in debug
  209. self.logger.info("%s request at %s received",
  210. environ["REQUEST_METHOD"], environ["PATH_INFO"])
  211. headers = pprint.pformat(self.headers_log(environ))
  212. self.logger.debug("Request headers:\n%s", headers)
  213. # Strip base_prefix from request URI
  214. base_prefix = self.configuration.get("server", "base_prefix")
  215. if environ["PATH_INFO"].startswith(base_prefix):
  216. environ["PATH_INFO"] = environ["PATH_INFO"][len(base_prefix):]
  217. elif self.configuration.get("server", "can_skip_base_prefix"):
  218. self.logger.debug(
  219. "Prefix already stripped from path: %s", environ["PATH_INFO"])
  220. else:
  221. # Request path not starting with base_prefix, not allowed
  222. self.logger.debug(
  223. "Path not starting with prefix: %s", environ["PATH_INFO"])
  224. return response(*NOT_ALLOWED)
  225. # Sanitize request URI
  226. environ["PATH_INFO"] = storage.sanitize_path(
  227. unquote(environ["PATH_INFO"]))
  228. self.logger.debug("Sanitized path: %s", environ["PATH_INFO"])
  229. path = environ["PATH_INFO"]
  230. # Get function corresponding to method
  231. function = getattr(self, "do_%s" % environ["REQUEST_METHOD"].upper())
  232. # Ask authentication backend to check rights
  233. authorization = environ.get("HTTP_AUTHORIZATION", None)
  234. if authorization and authorization.startswith("Basic"):
  235. authorization = authorization[len("Basic"):].strip()
  236. user, password = self.decode(base64.b64decode(
  237. authorization.encode("ascii")), environ).split(":", 1)
  238. else:
  239. user = environ.get("REMOTE_USER")
  240. password = None
  241. # If "/.well-known" is not available, clients query "/"
  242. if path == "/.well-known" or path.startswith("/.well-known/"):
  243. return response(client.NOT_FOUND, {})
  244. if user and not storage.is_safe_path_component(user):
  245. # Prevent usernames like "user/calendar.ics"
  246. self.logger.info("Refused unsafe username: %s", user)
  247. is_authenticated = False
  248. else:
  249. is_authenticated = self.is_authenticated(user, password)
  250. is_valid_user = is_authenticated or not user
  251. # Create principal collection
  252. if user and is_authenticated:
  253. principal_path = "/%s/" % user
  254. if self.authorized(user, principal_path, "w"):
  255. with self.Collection.acquire_lock("r", user):
  256. principal = next(
  257. self.Collection.discover(principal_path, depth="1"),
  258. None)
  259. if not principal:
  260. with self.Collection.acquire_lock("w", user):
  261. self.Collection.create_collection(principal_path)
  262. # Verify content length
  263. content_length = int(environ.get("CONTENT_LENGTH") or 0)
  264. if content_length:
  265. max_content_length = self.configuration.getint(
  266. "server", "max_content_length")
  267. if max_content_length and content_length > max_content_length:
  268. self.logger.debug(
  269. "Request body too large: %d", content_length)
  270. return response(client.REQUEST_ENTITY_TOO_LARGE)
  271. if is_valid_user:
  272. try:
  273. status, headers, answer = function(environ, path, user)
  274. except socket.timeout:
  275. return response(client.REQUEST_TIMEOUT)
  276. else:
  277. status, headers, answer = NOT_ALLOWED
  278. if (status, headers, answer) == NOT_ALLOWED and not (
  279. user and is_authenticated):
  280. # Unknown or unauthorized user
  281. self.logger.info("%s refused" % (user or "Anonymous user"))
  282. status = client.UNAUTHORIZED
  283. realm = self.configuration.get("server", "realm")
  284. headers = {
  285. "WWW-Authenticate":
  286. "Basic realm=\"%s\"" % realm}
  287. answer = None
  288. # Set content length
  289. if answer:
  290. self.logger.debug("Response content:\n%s", answer)
  291. answer = answer.encode(self.encoding)
  292. accept_encoding = [
  293. encoding.strip() for encoding in
  294. environ.get("HTTP_ACCEPT_ENCODING", "").split(",")
  295. if encoding.strip()]
  296. if "gzip" in accept_encoding:
  297. zcomp = zlib.compressobj(wbits=16 + zlib.MAX_WBITS)
  298. answer = zcomp.compress(answer) + zcomp.flush()
  299. headers["Content-Encoding"] = "gzip"
  300. headers["Content-Length"] = str(len(answer))
  301. # Add extra headers set in configuration
  302. if self.configuration.has_section("headers"):
  303. for key in self.configuration.options("headers"):
  304. headers[key] = self.configuration.get("headers", key)
  305. return response(status, headers, answer)
  306. def _access(self, user, path, permission, item=None):
  307. """Check if ``user`` can access ``path`` or the parent collection.
  308. ``permission`` must either be "r" or "w".
  309. If ``item`` is given, only access to that class of item is checked.
  310. """
  311. path = storage.sanitize_path(path)
  312. parent_path = storage.sanitize_path(
  313. "/%s/" % posixpath.dirname(path.strip("/")))
  314. allowed = False
  315. if not item or isinstance(item, self.Collection):
  316. allowed |= self.authorized(user, path, permission)
  317. if not item or not isinstance(item, self.Collection):
  318. allowed |= self.authorized(user, parent_path, permission)
  319. return allowed
  320. def _read_content(self, environ):
  321. content_length = int(environ.get("CONTENT_LENGTH") or 0)
  322. if content_length > 0:
  323. content = self.decode(
  324. environ["wsgi.input"].read(content_length), environ)
  325. self.logger.debug("Request content:\n%s", content.strip())
  326. else:
  327. content = None
  328. return content
  329. def do_DELETE(self, environ, path, user):
  330. """Manage DELETE request."""
  331. if not self._access(user, path, "w"):
  332. return NOT_ALLOWED
  333. with self.Collection.acquire_lock("w", user):
  334. item = next(self.Collection.discover(path), None)
  335. if not self._access(user, path, "w", item):
  336. return NOT_ALLOWED
  337. if not item:
  338. return client.GONE, {}, None
  339. if_match = environ.get("HTTP_IF_MATCH", "*")
  340. if if_match not in ("*", item.etag):
  341. # ETag precondition not verified, do not delete item
  342. return client.PRECONDITION_FAILED, {}, None
  343. if isinstance(item, self.Collection):
  344. answer = xmlutils.delete(path, item)
  345. else:
  346. answer = xmlutils.delete(path, item.collection, item.href)
  347. return client.OK, {}, answer
  348. def do_GET(self, environ, path, user):
  349. """Manage GET request."""
  350. # Display a "Radicale works!" message if the root URL is requested
  351. if not path.strip("/"):
  352. headers = {"Content-type": "text/html"}
  353. answer = "<!DOCTYPE html>\n<title>Radicale</title>Radicale works!"
  354. return client.OK, headers, answer
  355. if not self._access(user, path, "r"):
  356. return NOT_ALLOWED
  357. with self.Collection.acquire_lock("r", user):
  358. item = next(self.Collection.discover(path), None)
  359. if not self._access(user, path, "r", item):
  360. return NOT_ALLOWED
  361. if not item:
  362. return client.NOT_FOUND, {}, None
  363. if isinstance(item, self.Collection):
  364. collection = item
  365. else:
  366. collection = item.collection
  367. content_type = xmlutils.MIMETYPES.get(
  368. collection.get_meta("tag"), "text/plain")
  369. headers = {
  370. "Content-Type": content_type,
  371. "Last-Modified": collection.last_modified,
  372. "ETag": item.etag}
  373. answer = item.serialize()
  374. return client.OK, headers, answer
  375. def do_HEAD(self, environ, path, user):
  376. """Manage HEAD request."""
  377. status, headers, answer = self.do_GET(environ, path, user)
  378. return status, headers, None
  379. def do_MKCALENDAR(self, environ, path, user):
  380. """Manage MKCALENDAR request."""
  381. if not self.authorized(user, path, "w"):
  382. return NOT_ALLOWED
  383. content = self._read_content(environ)
  384. with self.Collection.acquire_lock("w", user):
  385. item = next(self.Collection.discover(path), None)
  386. if item:
  387. return client.CONFLICT, {}, None
  388. props = xmlutils.props_from_request(content)
  389. props["tag"] = "VCALENDAR"
  390. # TODO: use this?
  391. # timezone = props.get("C:calendar-timezone")
  392. self.Collection.create_collection(path, props=props)
  393. return client.CREATED, {}, None
  394. def do_MKCOL(self, environ, path, user):
  395. """Manage MKCOL request."""
  396. if not self.authorized(user, path, "w"):
  397. return NOT_ALLOWED
  398. content = self._read_content(environ)
  399. with self.Collection.acquire_lock("w", user):
  400. item = next(self.Collection.discover(path), None)
  401. if item:
  402. return client.CONFLICT, {}, None
  403. props = xmlutils.props_from_request(content)
  404. self.Collection.create_collection(path, props=props)
  405. return client.CREATED, {}, None
  406. def do_MOVE(self, environ, path, user):
  407. """Manage MOVE request."""
  408. to_url = urlparse(environ["HTTP_DESTINATION"])
  409. if to_url.netloc != environ["HTTP_HOST"]:
  410. # Remote destination server, not supported
  411. return client.BAD_GATEWAY, {}, None
  412. if not self._access(user, path, "w"):
  413. return NOT_ALLOWED
  414. to_path = storage.sanitize_path(to_url.path)
  415. if not self._access(user, to_path, "w"):
  416. return NOT_ALLOWED
  417. with self.Collection.acquire_lock("w", user):
  418. item = next(self.Collection.discover(path), None)
  419. if not self._access(user, path, "w", item):
  420. return NOT_ALLOWED
  421. if not self._access(user, to_path, "w", item):
  422. return NOT_ALLOWED
  423. if not item:
  424. return client.GONE, {}, None
  425. if isinstance(item, self.Collection):
  426. return client.CONFLICT, {}, None
  427. to_item = next(self.Collection.discover(to_path), None)
  428. if (isinstance(to_item, self.Collection) or
  429. to_item and environ.get("HTTP_OVERWRITE", "F") != "T"):
  430. return client.CONFLICT, {}, None
  431. to_parent_path = storage.sanitize_path(
  432. "/%s/" % posixpath.dirname(to_path.strip("/")))
  433. to_collection = next(
  434. self.Collection.discover(to_parent_path), None)
  435. if not to_collection:
  436. return client.CONFLICT, {}, None
  437. to_href = posixpath.basename(to_path.strip("/"))
  438. self.Collection.move(item, to_collection, to_href)
  439. return client.CREATED, {}, None
  440. def do_OPTIONS(self, environ, path, user):
  441. """Manage OPTIONS request."""
  442. headers = {
  443. "Allow": ", ".join(
  444. name[3:] for name in dir(self) if name.startswith("do_")),
  445. "DAV": DAV_HEADERS}
  446. return client.OK, headers, None
  447. def do_PROPFIND(self, environ, path, user):
  448. """Manage PROPFIND request."""
  449. if not self._access(user, path, "r"):
  450. return NOT_ALLOWED
  451. content = self._read_content(environ)
  452. with self.Collection.acquire_lock("r", user):
  453. items = self.Collection.discover(
  454. path, environ.get("HTTP_DEPTH", "0"))
  455. # take root item for rights checking
  456. item = next(items, None)
  457. if not self._access(user, path, "r", item):
  458. return NOT_ALLOWED
  459. if not item:
  460. return client.NOT_FOUND, {}, None
  461. # put item back
  462. items = itertools.chain([item], items)
  463. read_items, write_items = self.collect_allowed_items(items, user)
  464. headers = {"DAV": DAV_HEADERS, "Content-Type": "text/xml"}
  465. status, answer = xmlutils.propfind(
  466. path, content, read_items, write_items, user)
  467. if status == client.FORBIDDEN:
  468. return NOT_ALLOWED
  469. else:
  470. return status, headers, answer
  471. def do_PROPPATCH(self, environ, path, user):
  472. """Manage PROPPATCH request."""
  473. if not self.authorized(user, path, "w"):
  474. return NOT_ALLOWED
  475. content = self._read_content(environ)
  476. with self.Collection.acquire_lock("w", user):
  477. item = next(self.Collection.discover(path), None)
  478. if not isinstance(item, self.Collection):
  479. return client.CONFLICT, {}, None
  480. headers = {"DAV": DAV_HEADERS, "Content-Type": "text/xml"}
  481. answer = xmlutils.proppatch(path, content, item)
  482. return client.MULTI_STATUS, headers, answer
  483. def do_PUT(self, environ, path, user):
  484. """Manage PUT request."""
  485. if not self._access(user, path, "w"):
  486. return NOT_ALLOWED
  487. content = self._read_content(environ)
  488. with self.Collection.acquire_lock("w", user):
  489. parent_path = storage.sanitize_path(
  490. "/%s/" % posixpath.dirname(path.strip("/")))
  491. item = next(self.Collection.discover(path), None)
  492. parent_item = next(self.Collection.discover(parent_path), None)
  493. write_whole_collection = (
  494. isinstance(item, self.Collection) or
  495. not parent_item or (
  496. not next(parent_item.list(), None) and
  497. parent_item.get_meta("tag") not in (
  498. "VADDRESSBOOK", "VCALENDAR")))
  499. if write_whole_collection:
  500. if not self.authorized(user, path, "w"):
  501. return NOT_ALLOWED
  502. elif not self.authorized(user, parent_path, "w"):
  503. return NOT_ALLOWED
  504. etag = environ.get("HTTP_IF_MATCH", "")
  505. if not item and etag:
  506. # Etag asked but no item found: item has been removed
  507. return client.PRECONDITION_FAILED, {}, None
  508. if item and etag and item.etag != etag:
  509. # Etag asked but item not matching: item has changed
  510. return client.PRECONDITION_FAILED, {}, None
  511. match = environ.get("HTTP_IF_NONE_MATCH", "") == "*"
  512. if item and match:
  513. # Creation asked but item found: item can't be replaced
  514. return client.PRECONDITION_FAILED, {}, None
  515. items = list(vobject.readComponents(content or ""))
  516. content_type = environ.get("CONTENT_TYPE", "").split(";")[0]
  517. tags = {value: key for key, value in xmlutils.MIMETYPES.items()}
  518. tag = tags.get(content_type)
  519. if write_whole_collection:
  520. new_item = self.Collection.create_collection(
  521. path, items, {"tag": tag})
  522. else:
  523. if tag:
  524. parent_item.set_meta({"tag": tag})
  525. href = posixpath.basename(path.strip("/"))
  526. new_item = parent_item.upload(href, items[0])
  527. headers = {"ETag": new_item.etag}
  528. return client.CREATED, headers, None
  529. def do_REPORT(self, environ, path, user):
  530. """Manage REPORT request."""
  531. if not self._access(user, path, "w"):
  532. return NOT_ALLOWED
  533. content = self._read_content(environ)
  534. with self.Collection.acquire_lock("r", user):
  535. item = next(self.Collection.discover(path), None)
  536. if not self._access(user, path, "w", item):
  537. return NOT_ALLOWED
  538. if not item:
  539. return client.NOT_FOUND, {}, None
  540. if isinstance(item, self.Collection):
  541. collection = item
  542. else:
  543. collection = item.collection
  544. headers = {"Content-Type": "text/xml"}
  545. answer = xmlutils.report(path, content, collection)
  546. return client.MULTI_STATUS, headers, answer