mholt / caddy-webdav

WebDAV handler module for Caddy
Apache License 2.0
198 stars 22 forks source link

webdav sub path not working #7

Closed faicker closed 4 years ago

faicker commented 4 years ago
{
        order webdav last
}

:8001 {
  webdav /share/* {
        root ./share
    }
}

not working.

wader commented 4 years ago

Can you provide some details what happens, logs, examples request/response and what you expected?

Also see comment about prefix https://github.com/mholt/caddy-webdav/blob/master/webdav.go#L29

wader commented 4 years ago

@mholt maybe prefix should be documented somewhere, like in README?

faicker commented 4 years ago

thanks. If the prefix is added, The upload is working.

prefix /share
mholt commented 4 years ago

Yeah, the readme should probably be updated.

It's a bit unfortunate that prefix is needed at all, since Caddy is capable of manipulating the URI with its other directives. But I don't know how to make our webdav dependency work without the prefix in certain situations. It'd be nice to find a way to not need that anymore.

wader commented 4 years ago

I've tried to come up with something also but failed so far. Somehow keep track of matchers and or uri changes to let directives know what the "original" prefix is seems very messy? and in the webdav case i guess it would only work with some kind a match patterns?

As I understand the webdav spec the root of the issue is that the "href" response element for PROPFIND is required to be a URI or a "relative reference" which seems to mean an absolute path. Maybe this should be mentioned somehow?

mholt commented 4 years ago

Somehow keep track of matchers and or uri changes to let directives know what the "original" prefix is seems very messy?

I was thinking more like:

handle_path /path/* {
    webdav
}

but if the webdav handler is crafting URIs for the response, it will still need to know that the /path portion of the URI existed before it was stripped. This is actually available through orig_uri placeholders, but of course the webdav library dependency doesn't know about those...

wader commented 4 years ago

Aha, could the default prefix value be some placeholder variable similar to how the root default value "{http.vars.root}" works? but i wonder how one could keep track of what part of the uri that has been matched and what part to pass as path to webdav library? sorry if misunderstand or is using the wrong caddy terminology, haven't digged much into caddy internal yet :)

wader commented 4 years ago

@faicker can close?

mholt commented 4 years ago

@wader I get what you mean. It could probably be done with regular expressions, where you can name a capture group and then refer to those with placeholders in the subsequent route. But that seems like overkill...

wader commented 4 years ago

@mholt That could work :) but i agree hard to find a elegant solution it seems

faicker commented 4 years ago

@wader yes, thanks.