You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As get_props is meant to read properties of a single filepath, it seems relevant to add Depth: 0 to the headers in this method.
Here is a fix which is working for me:
defget_props(
self,
path: str,
name: Optional[str] =None,
namespace: Optional[str] =None,
data: Optional[str] =None,
) ->"DAVProperties":
"""Returns properties of a resource by doing a propfind request. Can also selectively request the properties by passing name or data. """data=dataorprepare_propfind_request_data(name, namespace)
headers= {"Content-Type": "application/xml"} ifdataelse {}
headers["Depth"] ="0"# <-- This line enforce the Depth headerresult=self.propfind(path, headers=headers, data=data)
response=result.get_response_for_path(self.base_url.path, path)
returnresponse.properties
But I am not sure of the all the consequences, maybe I’m missing the big picture. I did not test this with another webdav server like Nextcloud.
What do you think?
The text was updated successfully, but these errors were encountered:
A client MUST submit a Depth header with a value of "0", "1", or
"infinity" with a PROPFIND request. Servers MUST support "0" and "1"
depth requests on WebDAV-compliant resources and SHOULD support
"infinity" requests. In practice, support for infinite-depth
requests MAY be disabled, due to the performance and security
concerns associated with this behavior. Servers SHOULD treat a
request without a Depth header as if a "Depth: infinity" header was
included.
get_props() should most definitely be updated to send an appropriate Depth header.
Note: not all servers support Depth: infinity.
lighttpd supports Depth: infinity, but disables PROPFIND Depth: infinity by default, unless explicitly configured in lighttpd.conf: webdav.opts += ("propfind-depth-infinity" => "enable")
Therefore, if you send Depth: infinity, you should be prepared to fall back to multiple PROPFIND requests with Depth: 1
Observations
When using lighttpd webdav module as a webdav server.
When using get_props on a resource (directory or file).
The following exception is raised:
This is because propfind returns an empty content (the XML is valid, but with no data).
Solution
After several tests I found out that
propfind
works well if the correctDepth
header.Depth: 1
as used by ls is listing files correctly.Depth: 0
allows to get properties of a single filepath. Example below:As
get_props
is meant to read properties of a single filepath, it seems relevant to addDepth: 0
to the headers in this method.Here is a fix which is working for me:
But I am not sure of the all the consequences, maybe I’m missing the big picture. I did not test this with another webdav server like Nextcloud.
What do you think?
The text was updated successfully, but these errors were encountered: