Skip to content

feat(webdav): download from WebDAV servers with resume - #583

Merged
linroid merged 4 commits into
mainfrom
feat/webdav
Oct 18, 2026
Merged

linroid merged 4 commits into
mainfrom
feat/webdav

Conversation

@linroid

@linroid linroid commented Oct 17, 2026

Copy link
Copy Markdown
Owner

Implements the WebDAV roadmap item: download files from WebDAV servers (Nextcloud, ownCloud, a NAS, Apache mod_dav, IIS…), with parallel connections and resume.

What changed

New library:webdav module (same targets as core) with WebDavDownloadSource(httpEngine):

  • Links: webdav:// / dav:// over HTTP, webdavs:// / davs:// over HTTPS.
  • Every resolve and run sends a PROPFIND (Depth: 0) for size, getetag, getlastmodified, content type and resourcetype. Folders are refused. Servers answering 403/405/501 (or taking PROPFIND for GET) are read from their headers instead.
  • A probe of the first byte tells range support. Files then download in segments through SegmentedDownloadHelper, with the watchdog, throttling and live connection reporting as for HTTP. Content of unknown size is streamed.
  • Resume continues from the bytes written. It fails with FileChanged when the ETag (weak prefix and quotes ignored), else the modification time, or the size differs.
  • Sign-in: credentials come from the link's user info, else from an Authorization: Basic header (what the apps' Sign in adds). Nothing is sent before a 401. Digest (RFC 7616: SHA-256 or MD5, -sess, qop=auth, userhash) is used when offered, else Basic, with a warning over plain HTTP. A nonce that expires mid-download is answered again once. Missing or refused credentials give AuthenticationFailed.
  • Contains a small namespace-aware XML reader for multistatus answers. It never expands DTD entities, caps nesting depth, and reads at most 1 MiB.

Core and Ktor

  • New HttpEngine.request(method, url, headers, body, maxBodyBytes): HttpReply for requests other than downloads. It returns the status and headers of any status, so callers can read WWW-Authenticate. Its default throws UnsupportedOperationException. It is implemented by KtorHttpEngine (same redirect and header rules as other requests; never reads a HEAD body) and passed on by MultiNetworkHttpEngine and ConfigurableNetworkHttpEngine.
  • httpConnectionSpec and observeExchanges are now public, so sources outside core can report connections like HTTP does.

Apps, CLI, server

  • The source is registered by the desktop, Android and iOS apps, the CLI (ketch <url>, --list-files, server, mcp --standalone) and the native-desktop prototype.
  • LinkKind.WebDav makes pasted and typed links parse, quick add and work in the palette.

Docs: new docs/webdav.md. Also updated: the README and its five translations (feature added, roadmap item removed), docs/api.md, docs/developers.md, docs/architecture.md and AGENTS.md.

Testing

  • :library:webdav:allTests: JVM, Android host, JS and WasmWasi. Covers the RFC 2617 and RFC 7616 Digest vectors, challenge parsing, XML and multistatus parsing, URL handling, and the source against FakeDavServer (segments, no ranges, unknown size, Digest, stale nonce, Basic header, bearer passthrough, wrong credentials, resume, changed file, emptied local file).
  • WebDavIntegrationTest (jvmTest): a JDK HttpServer requiring Digest, driven through KtorHttpEngine and a real Ketch. Covers a segmented download, pause/resume from the right byte with a rotated nonce, a changed file, a wrong password, a folder, and a link with unencoded spaces and CJK characters.
  • :library:core:jvmTest and :library:ktor:jvmTest (5 new tests for request) pass, as do the LinkParserTest and IntakeProblemsTest app tests.
  • Compiles: :cli, :app:desktop, :app:android (direct debug), :app:shared for iOS simulator, and the webdav module's iOS tests.
  • Not run: the desktop ProGuard release build and the GraalVM native CLI build.

Limits

One file per link (no collection downloads), no NTLM/Negotiate, and no Digest auth-int.

Add library:webdav with WebDavDownloadSource for webdav(s):// and dav(s)://
links: PROPFIND for size, ETag and modification time (folders refused,
plain HTTP headers when PROPFIND is refused), segmented ranged GETs,
resume that fails with FileChanged when the file changed, and Digest
(RFC 7616) or Basic sign-in from the link or an Authorization: Basic
header.

Add HttpEngine.request for requests other than downloads, implemented by
KtorHttpEngine and the network engines, and make httpConnectionSpec and
observeExchanges public. Register the source in the apps, CLI and server,
recognize the links in the apps, and document it.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-17T16:25:33.525139Z 5c3f765 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5c3f76584e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

…rects

Send If-Match with the probe's strong ETag, else If-Unmodified-Since,
with every segment GET, and fail a 412 with FileChanged, so a file
replaced mid-download is never stitched from two versions.

Resume compares strong ETags only, falling back to Last-Modified; a weak
tag is never compared, and a file with neither validator starts over.

HttpReply now reports the URL that answered, and the WebDAV client moves
to the target of a same-origin redirect, so Digest answers name the path
the server checks.
@github-actions

Copy link
Copy Markdown
Contributor

Test Results

 2 064 files  + 16   2 092 suites  +16   33m 7s ⏱️ -29s
13 877 tests +161  13 613 ✅ +161  264 💤 ±0  0 ❌ ±0 
16 868 runs  +161  16 604 ✅ +161  264 💤 ±0  0 ❌ ±0 

Results for commit e3ec510. ± Comparison against base commit 2462373.

@linroid
linroid merged commit 455382b into main Oct 18, 2026
11 checks passed
@linroid
linroid deleted the feat/webdav branch October 18, 2026 00:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant