Module Webdavz.Handler

WebDAV handler generation from a storage backend.

Given any module implementing the STORE interface, this module generates a complete set of RFC 4918 WebDAV routes suitable for use with Httpz_server.Route.

Supported Methods

  Method     Section    Status
  ────────   ────────   ──────────────────────────
  PROPFIND   9.1        207 Multi-Status / 400 Bad Depth
  PROPPATCH  9.2        403 Forbidden (stub, DAV:error XML)
  MKCOL      9.3        201 / 405 / 409 / 415
  GET        9.4        200 OK / 404 Not Found
  PUT        9.7        201 + ETag+Location / 204 + ETag / 409
  DELETE     9.6        204 No Content / 404 Not Found
  OPTIONS    9.8        200 OK (DAV: 1, 2)
  LOCK       9.10       200 OK / 201 Created / 423 Locked
  UNLOCK     9.11       204 No Content / 400 / 409

Compliance Notes

Storage Interface

The STORE module type abstracts the backend that holds WebDAV resources. Implementations might use a local filesystem (see Carddavz_store), an in-memory map, or a database.

module type RO_STORE = sig ... end

Read-only storage interface. Sufficient for serving resources via PROPFIND and GET without any mutating operations.

module type STORE = sig ... end

Route Generation

val routes : (module STORE with type t = 's) -> 's -> locks:Webdavz__.Webdavz_lock.t -> Httpz_server.Route.route list

routes (module S) store ~locks generates httpz routes implementing WebDAV class-2 compliance (with locking) for the given store.

Write operations (PUT, DELETE, MKCOL, PROPPATCH) check locks and return 423 Locked if the resource is locked without the correct token.

All routes use the Httpz_server.Route.tail pattern, so they match any path. Mount them at a prefix using literal path segments:

  let locks = Webdavz_lock.create () in
  let dav_routes = Webdavz_handler.routes (module My_store) store ~locks in
  let all_routes = Httpz_server.Route.of_list dav_routes
val read_only_routes : (module RO_STORE with type t = 's) -> 's -> Httpz_server.Route.route list

read_only_routes (module S) store generates read-only WebDAV routes.

Only PROPFIND, GET, and OPTIONS are functional. PUT, DELETE, MKCOL, and PROPPATCH return 403 Forbidden. The OPTIONS response advertises only GET, HEAD, PROPFIND.

  let routes = Webdavz_handler.read_only_routes (module My_ro_store) store in
  let route_table = Httpz_server.Route.of_list routes