webdav-handler
Generic async HTTP/WEBDAV handler
Webdav
(RFC4918) is HTTP (GET/HEAD/PUT/DELETE) plus a bunch of extra methods.
This crate implements a futures/stream based webdav handler for Rust, using
the types from the http
crate. It comes complete with an async filesystem
backend, so it can be used as a WEBDAV filesystem server, or just as a
feature-complete HTTP server.
Interface.
It has an interface similar to the Go x/net/webdav package:
- the library contains an HTTP handler
- you supply a filesystem for backend storage, which can optionally implement reading/writing DAV properties.
- you can supply a locksystem that handles the webdav locks
With some glue code, this handler can be used from HTTP server libraries/frameworks such as hyper. (See examples/hyper.rs).
Implemented standards.
Currently passes the "basic", "copymove", "props", "locks" and "http" checks of the Webdav Litmus Test testsuite. That's all of the base RFC4918 webdav specification.
The litmus test suite also has tests for RFC3744 "acl" and "principal", RFC5842 "bind", and RFC3253 "versioning". Those we do not support right now.
The relevant parts of the HTTP RFCs are also implemented, such as the preconditions (If-Match, If-None-Match, If-Modified-Since, If-Unmodified-Since, If-Range), partial transfers (Range).
Also implemented is partial PUT
, for which there are currently two
non-standard ways to do it: PUT
with the Content-Range
header,
which is what Apache's mod_dav
implements, and PATCH
with the X-Update-Range
header from SabreDav
.
Backends.
Included are two filesystems:
LocalFs
: serves a directory on the local filesystemMemFs
: ephemeral in-memory filesystem. supports DAV properties.
Also included are two locksystems:
MemLs
: ephemeral in-memory locksystem.FakeLs
: fake locksystem. just enough LOCK/UNLOCK support for OSX/Windows.
Example.
Example server that serves the /tmp directory in r/w mode. You should be able to mount this network share from Linux, OSX and Windows.
use ;
async
Building.
This crate uses std::future::Future and async/await, so it only works with Rust 1.39 and up.
Testing.
RUST_LOG=webdav_handler=debug cargo run --example sample-litmus-server
This will start a server on port 4918, serving an in-memory filesystem.
For other options, run cargo run --example sample-litmus-server -- --help
Copyright and License.
- © 2018, 2019 XS4ALL Internet bv
- © 2018, 2019 Miquel van Smoorenburg
- Apache License, Version 2.0