Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/Microsoft.Deployment.DotNet.Releases/src/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ internal class Utils
internal static async Task<bool> IsLatestFileAsync(string fileName, Uri address)
{
var httpRequest = new HttpRequestMessage(HttpMethod.Head, address);
HttpResponseMessage httpResponse = await s_httpClient.SendAsync(httpRequest).ConfigureAwait(false);
using HttpResponseMessage httpResponse = await s_httpClient.SendAsync(httpRequest).ConfigureAwait(false);

httpResponse.EnsureSuccessStatusCode();

Expand Down Expand Up @@ -61,7 +61,7 @@ internal static async Task DownloadFileAsync(Uri address, string fileName)
}
else
{
HttpResponseMessage httpResponse = await s_httpClient.GetAsync(address).ConfigureAwait(false);
using HttpResponseMessage httpResponse = await s_httpClient.GetAsync(address).ConfigureAwait(false);
httpResponse.EnsureSuccessStatusCode();

using FileStream stream = File.Create(fileName);
Expand Down Expand Up @@ -149,7 +149,7 @@ internal static async Task GetLatestFileAsync(string path, bool downloadLatest,

static Utils()
{
s_httpClient = new HttpClient();
s_httpClient = new HttpClient(new HttpClientHandler(), disposeHandler: true);
s_httpClient.DefaultRequestHeaders.CacheControl = new CacheControlHeaderValue
{
NoCache = true
Expand Down