public async Task <EntityVersion <WebResourceName, string> > UpdateEntity(WebResourceName url, string etag, string contents) { s_logger.DebugFormat("Updating entity '{0}'", url); var absoluteContactUrl = new Uri(_serverUrl, url.OriginalAbsolutePath); s_logger.DebugFormat("Absolute entity location: '{0}'", absoluteContactUrl); IHttpHeaders responseHeaders = await _webDavClient.ExecuteWebDavRequestAndReturnResponseHeaders( absoluteContactUrl, "PUT", null, etag, null, "text/vcard", contents); if (s_logger.IsDebugEnabled) { s_logger.DebugFormat("Updated entity. Server response header: '{0}'", responseHeaders.ToString().Replace("\r\n", " <CR> ")); } Uri effectiveContactUrl; if (responseHeaders.Location != null) { s_logger.DebugFormat("Server sent new location: '{0}'", responseHeaders.Location); effectiveContactUrl = responseHeaders.Location.IsAbsoluteUri ? responseHeaders.Location : new Uri(_serverUrl, responseHeaders.Location); s_logger.DebugFormat("New entity location: '{0}'", effectiveContactUrl); } else { effectiveContactUrl = absoluteContactUrl; } var newEtag = responseHeaders.ETag; string version; if (newEtag != null) { version = newEtag; } else { version = await GetEtag(effectiveContactUrl); } return(new EntityVersion <WebResourceName, string> (new WebResourceName(effectiveContactUrl), version)); }