WebDavClient icon indicating copy to clipboard operation
WebDavClient copied to clipboard

The DEPTH option "1,noroot" should be added

Open zspasojevic opened this issue 5 years ago • 3 comments

Hi,

The plugin as I see currently only supports options to fetch properties for resource itself, resource + children and the infinite one. In a situation where I need to fetch the files tree I want to fetch only children for each call and that can be done with "1,noroot" depth setting. For clarification, at the moment when I fetch the "Images" folder props I get => Images folder, image1.jpg, image2.jpg etc. I want only the images, not the selected folder.

image

https://docs.microsoft.com/en-us/previous-versions/office/developer/exchange-server-2003/aa142960%28v%3dexchg.65%29

zspasojevic avatar Nov 14 '19 15:11 zspasojevic

Thank you for reporting this. I didn't know about 1,noroot, it turns out to be an extension from Microsoft and not a part of the original spec (as well as infinity,noroot). I marked it as up-for-grabs and I can accept a Pull Request for this if you or someone else wants to add support for it (would be nice to include infinity,noroot as well).

Could be worked around by sending a custom Depth header, though

Headers = new List<KeyValuePair<string, string>>
{
  new KeyValuePair<string, string>("Depth", "1,noroot")
}

skazantsev avatar Dec 21 '19 23:12 skazantsev

Thanks for the response. I'll be glad to make a PR for this. Workaround is giving me a 400 bad request, maybe I'm not using it in the right way. Can you show me an example of setting the PropfindParameters to send with this custom header.

zspasojevic avatar Dec 27 '19 13:12 zspasojevic

Sure, here is an example:

var propfindParams = new PropfindParameters
{
  Headers = new List<KeyValuePair<string, string>>
  {
    new KeyValuePair<string, string>("Depth", "1,noroot")
  }
};
var response = await client.Propfind("__URL__", propfindParams);

I checked that a request with this header is sent but I cannot check that it actually works since I don't have a WebDAV server that supports this header.

I wonder why the server returns 400 in your case, probably there's error details in the response body. Fiddler or other HTTP debugging tools could help here.

skazantsev avatar Dec 28 '19 13:12 skazantsev