To list properties of a directory we must use the PROPFIND
method of WebDAV protocol and provide a request body with properties we are interested into.
We must also provide the Depth
header (otherwise the request is rejected as 403 Forbidden
).
To retrieve basic properties as size and type, prepare a request body (say propfind-basic.xml
) as:
<propfind xmlns="DAV:">
<prop>
<getlastmodified xmlns="DAV:"/>
<getcontentlength xmlns="DAV:"/>
<executable xmlns="http://apache.org/dav/props/"/>
<resourcetype xmlns="DAV:"/>
</prop>
</propfind>
To find all available properties (without their values), prepare a request body (say propfind-available.xml
) as:
<?xml version="1.0" encoding="utf-8" ?>
<propfind xmlns="DAV:">
<propname/>
</propfind>
Perform the request:
curl -v -X PROPFIND \
-H "Content-Type: application/xml" -H "Accept: application/xml" \
-H "Depth: 1" \
-d @propfind.xml http://webdav.internal/
An example configuration for Apache2's mod_dav
module:
Alias "/files" "/var/www/html"
<Location "/files">
DAV on
AllowOverride none
Options +Indexes
DirectoryIndex disabled
AuthType Basic
AuthName "WebDAV Area"
AuthDigestProvider file
AuthUserFile "/etc/apache2/passwd"
Require user "admin"
</Location>