Henrique Dias Henrique Dias - 1 month ago 4
HTTP Question

How to know if the HTTP request comes from an WebDav client?

I'm creating a web file manager and it was recently suggested to me to implement WebDav on it and I thought it is a really nice idea.

I thought about keeping the webdav in a separate URL like

/webdav
but now I'm thinking about keeping both the web interface I created and the webdav server at the same URL.

In order to know if I should provide an HTML page or the file I need to know if it is being accessed from a browser OR from a webdav server. How should I know that? Is the User-Agent enough?

If so, which user-agents should I treat as a WebDav client?

Thanks!

Answer

You could potentially use something like Authenticated vs unauthenticated in order to determine, but as @evert says don't do this. also reading the DAV specs (RFC 2518) (http://www.webdav.org/specs/rfc2518.html)

In the absence of distributed authoring capabilities, it is acceptable to have no mapping of source resource(s) to the URI namespace. In fact, preventing access to the source resource(s) has desirable security benefits. However, if remote editing of the source resource(s) is desired, the source resource(s) should be given a location in the URI namespace. This source location should not be one of the locations at which the generated output is retrievable, since in general it is impossible for the server to differentiate requests for source resources from requests for process output resources. There is often a many-to-many relationship between source resources and output resources.

the Important part here is

This source location should not be one of the locations at which the >generated output is retrievable, since in general it is impossible for the >server to differentiate requests for source resources from requests for >process output resources