mirror of
https://github.com/collinbarrett/FilterLists.git
synced 2026-03-11 09:04:27 +00:00
caller of GetAsStreamAsync() should handle disposal of Stream, HttpResponseMessage doesn't necessarily need disposing itself
This commit is contained in:
parent
679cf67107
commit
9eb27bd787
1 changed files with 3 additions and 1 deletions
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.IO;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
|
|
@ -27,9 +28,10 @@ public ListRepository(HttpClient httpClient, ILogger<ListRepository> logger)
|
|||
_logger = logger;
|
||||
}
|
||||
|
||||
[SuppressMessage("Microsoft.Reliability", "CA2000:DisposeObjectsBeforeLosingScope")]
|
||||
public async Task<Stream> GetAsStreamAsync(Uri url, CancellationToken cancellationToken)
|
||||
{
|
||||
using var response = await _httpClient.GetAsync(url, cancellationToken);
|
||||
var response = await _httpClient.GetAsync(url, cancellationToken);
|
||||
if (response.IsSuccessStatusCode)
|
||||
return await response.Content.ReadAsStreamAsync();
|
||||
_logger.LogError($"Error downloading list from {url}. {response.StatusCode}");
|
||||
|
|
|
|||
Loading…
Reference in a new issue