torb/webdav - WebDAV storage driver for TorbScript (webdav and webdavs schemes)
  • Python 98.6%
  • Shell 1.4%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-11-15 14:45:50 +00:00
.forgejo/workflows Initial commit 2026-11-15 13:28:52 +00:00
.githooks Initial commit 2026-11-15 13:28:52 +00:00
.github/workflows Initial commit 2026-11-15 13:28:52 +00:00
examples feat: WebDavStorage driver for webdav and webdavs references 2026-11-15 14:40:13 +01:00
src feat: WebDavStorage driver for webdav and webdavs references 2026-11-15 14:40:13 +01:00
tests feat: WebDavStorage driver for webdav and webdavs references 2026-11-15 14:40:13 +01:00
tools/pdisc Initial commit 2026-11-15 13:28:52 +00:00
.gitignore Initial commit 2026-11-15 13:28:52 +00:00
.pdisc.yaml feat: WebDavStorage driver for webdav and webdavs references 2026-11-15 14:40:13 +01:00
INDEX.md feat: WebDavStorage driver for webdav and webdavs references 2026-11-15 14:40:13 +01:00
LICENSE Initial commit 2026-11-15 13:28:52 +00:00
project.trb feat: WebDavStorage driver for webdav and webdavs references 2026-11-15 14:40:13 +01:00
README.md feat: WebDavStorage driver for webdav and webdavs references 2026-11-15 14:40:13 +01:00

title summary keywords type updated body_hash
torb/webdav: WebDAV storage driver for TorbScript README of torb/webdav, the std/storage driver for webdav: and webdavs: references: how to use WebDavStorage, which requests each member sends and what it leaves out (whole-body PUT, no locking, no ETag handling). Read before storing files on a WebDAV server.
webdav
webdavs
storage driver
webdavstorage
propfind
mkcol
http basic
reference 2026-11-15 d1ed6f63345a

torb/webdav

WebDAV as a Storage of TorbScript: WebDavStorage reads, lists, writes and deletes the files of Nextcloud, ownCloud, a NAS or Apache's mod_dav through the trait of std/storage, so the program that holds a Storage does not know that its bytes are on a server.

use WebDavStorage from "torb/webdav"

fn notes(): Task<Result<List<Uri>, StorageFailure>> {
  var storage = WebDavStorage user: "ada", password: "secret"
  storage.writeText("webdavs://cloud.example.test/files/notes/first.txt", "one").await()?
  storage.list("webdavs://cloud.example.test/files/notes").await()
}

webdav://host/path is reached over http and webdavs://host/path over https. Hand the driver to Storage.registry and a program stores at memory:, file: and webdavs: references through one value.

What each member sends

Member Request Answer
read(uri) GET the body as Bytes; 404 is NotFound
exists(uri) HEAD true for a success, false for 404, no failure
list(uri) PROPFIND with Depth: 1, the reply read with Xml().decode the Uris directly below the collection, sorted, the collection itself left out; 404 is NotFound
write(uri, content) PUT of the whole content on a 409 (a collection above the file is missing) MKCOL of the missing collections from the top down, then the PUT once more
delete(uri) DELETE, which removes a collection with everything below it 404 is NotFound

Any other status, a reply above maximumReply (16 MiB by default) and a failed connection are StorageFailure.Refused with the status and its reason phrase, as status 403 Forbidden.

Credentials

HTTP Basic credentials are settings of the driver, WebDavStorage user:, password:, and never part of a reference. A reference with user information is NotAddressable, and every failure names its reference as Uri.show() writes it, so no failure text and no show of one holds a password. Send them over webdavs:: Basic over plain webdav: is readable on the wire.

Limits

  • Whole-body PUT. A write sends the whole Bytes in one request and a read holds the whole body in memory; there are no ranges, no chunked upload and no resume.
  • No locking. LOCK and UNLOCK are not sent, so a server that requires a lock token for a write refuses it, and two writers of one file do not know of each other.
  • No ETag handling. If-Match and If-None-Match are not sent and the ETag of a reply is not read, so a write replaces whatever is there.
  • No redirects. A 301 or 302 is a Refused; give the driver the address the server answers at.
  • Directory entries only by path. list reads the href of each response and nothing else of it: no sizes, dates or properties.

Developing

$ torb format --check .    # the layout torb format writes
$ torb check src tests examples
$ torb test tests          # tests/webdav.test.trb starts a WebDAV server of its own on a free port
$ torb doc --check src examples
$ torb run examples/backup.trb

The tests need no WebDAV server: tests/dav-server.trb is one over an in-memory tree, built from the Server of std/http, and each scenario starts it on port 0.

Files

webdav/
├─ project.trb              name, version, description, license
├─ src/
│  ├─ lib.trb                the package: "torb/webdav" resolves to this file
│  ├─ webdav.trb             WebDavStorage
│  └─ listing.trb            the PROPFIND request body and the reading of the 207 reply
├─ tests/
│  ├─ webdav.test.trb        every member against the test server
│  └─ dav-server.trb         the test server: GET, HEAD, PUT, MKCOL, DELETE and PROPFIND over a tree in memory
├─ examples/
│  └─ backup.trb             a file copied between two references
└─ .github/workflows/, .forgejo/workflows/   CI (push, pull request) and publish (tag v*)
  • std/storage - the Storage trait, MemoryStorage, FileStorage and Storage.registry.
  • RFC 4918 - HTTP Extensions for Web Distributed Authoring and Versioning.