httputils.py 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. # This file is part of Radicale Server - Calendar Server
  2. # Copyright © 2008 Nicolas Kandel
  3. # Copyright © 2008 Pascal Halter
  4. # Copyright © 2008-2017 Guillaume Ayoub
  5. # Copyright © 2017-2018 Unrud <unrud@outlook.com>
  6. #
  7. # This library is free software: you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation, either version 3 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # This library is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with Radicale. If not, see <http://www.gnu.org/licenses/>.
  19. """
  20. Helper functions for HTTP.
  21. """
  22. from http import client
  23. NOT_ALLOWED = (
  24. client.FORBIDDEN, (("Content-Type", "text/plain"),),
  25. "Access to the requested resource forbidden.")
  26. FORBIDDEN = (
  27. client.FORBIDDEN, (("Content-Type", "text/plain"),),
  28. "Action on the requested resource refused.")
  29. BAD_REQUEST = (
  30. client.BAD_REQUEST, (("Content-Type", "text/plain"),), "Bad Request")
  31. NOT_FOUND = (
  32. client.NOT_FOUND, (("Content-Type", "text/plain"),),
  33. "The requested resource could not be found.")
  34. CONFLICT = (
  35. client.CONFLICT, (("Content-Type", "text/plain"),),
  36. "Conflict in the request.")
  37. WEBDAV_PRECONDITION_FAILED = (
  38. client.CONFLICT, (("Content-Type", "text/plain"),),
  39. "WebDAV precondition failed.")
  40. METHOD_NOT_ALLOWED = (
  41. client.METHOD_NOT_ALLOWED, (("Content-Type", "text/plain"),),
  42. "The method is not allowed on the requested resource.")
  43. PRECONDITION_FAILED = (
  44. client.PRECONDITION_FAILED,
  45. (("Content-Type", "text/plain"),), "Precondition failed.")
  46. REQUEST_TIMEOUT = (
  47. client.REQUEST_TIMEOUT, (("Content-Type", "text/plain"),),
  48. "Connection timed out.")
  49. REQUEST_ENTITY_TOO_LARGE = (
  50. client.REQUEST_ENTITY_TOO_LARGE, (("Content-Type", "text/plain"),),
  51. "Request body too large.")
  52. REMOTE_DESTINATION = (
  53. client.BAD_GATEWAY, (("Content-Type", "text/plain"),),
  54. "Remote destination not supported.")
  55. DIRECTORY_LISTING = (
  56. client.FORBIDDEN, (("Content-Type", "text/plain"),),
  57. "Directory listings are not supported.")
  58. INTERNAL_SERVER_ERROR = (
  59. client.INTERNAL_SERVER_ERROR, (("Content-Type", "text/plain"),),
  60. "A server error occurred. Please contact the administrator.")
  61. DAV_HEADERS = "1, 2, 3, calendar-access, addressbook, extended-mkcol"