protected async Task<bool> HasOption (string requiredOption)
{
IHttpHeaders headers;
try
{
headers = await _webDavClient.ExecuteWebDavRequestAndReturnResponseHeaders(
_serverUrl,
"OPTIONS",
null,
null,
null,
null,
null);
}
catch (WebDavClientException x) when (x.StatusCode == HttpStatusCode.NotFound)
{
// iCloud and Google CardDav return with 404 and OPTIONS doesn't work for the resource uri
return true;
}
IEnumerable<string> davValues;
if (headers.TryGetValues ("DAV", out davValues))
{
return davValues.Any (
value => value.Split (new[] { ',' })
.Select (o => o.Trim())
.Any (option => String.Compare (option, requiredOption, StringComparison.OrdinalIgnoreCase) == 0));
}
else
{
return false;
}
}