private async Task <Stream> GetConsensusDocumentAsync(DirectoryAuthority da) { if (false) //File.Exists(da.Nickname)) { logger.Debug($"Using cached consensus document from {da.Nickname}"); return(File.OpenRead(da.Nickname)); } else { logger.Debug($"Downloading consensus document from {da.Url}"); using (var http = new HttpClient()) { var response = await http.GetAsync(da.Url, HttpCompletionOption.ResponseHeadersRead).ConfigureAwait(false); response.EnsureSuccessStatusCode(); return(await response.Content.ReadAsStreamAsync().ConfigureAwait(false)); } } }
private Task SaveConsensusDocumentAsync(DirectoryAuthority da, Stream contentStream) { using var file = File.OpenWrite(da.Nickname); return(contentStream.CopyToAsync(file)); }