Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webdav backend incompatible with golang stdlib webdav implementation #825

Open
SISheogorath opened this issue Dec 22, 2024 · 5 comments · May be fixed by #857
Open

Webdav backend incompatible with golang stdlib webdav implementation #825

SISheogorath opened this issue Dec 22, 2024 · 5 comments · May be fixed by #857
Assignees
Labels
🗄️ backend Related to a backup storage backend good first issue help wanted
Milestone

Comments

@SISheogorath
Copy link

I think I found conflict between how the seedvault implementation expects directories to work and how golang handles it:

In this function, you test that directories exist using the HEAD function:

internal fun DavCollection.ensureFoldersExist(log: KLogger, folders: MutableSet<HttpUrl>) {
if (location.pathSize <= 2) return
val parent = location.newBuilder()
.removePathSegment(location.pathSize - 1)
.build()
if (parent in folders) return
val parentCollection = DavCollection(httpClient, parent)
try {
parentCollection.head { response ->
log.debugLog { "head($parent) = $response" }
folders.add(parent)
}
} catch (e: NotFoundException) {
log.debugLog { "$parent not found, creating..." }
parentCollection.mkColCreateMissing { response ->
log.debugLog { "mkColCreateMissing($parent) = $response" }
folders.add(parent)
}
}
}

golang doesn't support HEAD requests on directory listings:
https://github.com/golang/net/blob/dfc720dfe0cfc125116068c20efcdcb5e4eab464/webdav/webdav.go#L212

I checked the RFCs RFC4918 and RFC2068 but couldn't find any defintive answer how this should be handled. But there isn't really an answer to this, beyond "Treat GET and HEAD identical". The overall internet also seems undecided how to handle directory requests in webdav. (Here one of the samples I found).

I think the correct way to check for directories would be the usage of PROPFIND with a depth of 0. That would certainly be in line with the RFC4918 section 9.1.

This is an upstream issue for downstream issue GrapheneOS/os-issue-tracker#4558

@grote grote added 🗄️ backend Related to a backup storage backend help wanted good first issue labels Dec 23, 2024
@grote
Copy link
Collaborator

grote commented Dec 23, 2024

shouldn't be too difficult to change the head request to propfind(depth=0).

@grote
Copy link
Collaborator

grote commented Jan 20, 2025

@martijnboers are you using https://github.com/mholt/caddy-webdav ? If so, it seems that also doesn't support HEAD requests. I am getting 405 from it.

@grote grote self-assigned this Jan 20, 2025
@grote grote added this to the Roadmap milestone Jan 20, 2025
@SISheogorath
Copy link
Author

@martijnboers
Copy link

martijnboers commented Jan 21, 2025

Yes I am using that caddy extension, I can setup a non-Go implementation for debugging if that helps. I was looking through the forks but it seems no one has bothered implementing HEAD requests.

@grote
Copy link
Collaborator

grote commented Jan 21, 2025

I am going to submit a PR that removes the HEAD request in favor of PROPFIND. With that it works fine against your caddy server and much much faster than going through SAF and DavX5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🗄️ backend Related to a backup storage backend good first issue help wanted
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants