From e766488e740851d0d432801b6ff597a0d8a417ce Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 6 May 2026 22:49:08 +0000 Subject: [PATCH 1/6] Initial plan From a981bdad2ead03618b42f876fa143b5ab265bd7f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 6 May 2026 22:51:39 +0000 Subject: [PATCH 2/6] Dispose HTTP request/response objects in releases utils Agent-Logs-Url: https://github.com/dotnet/deployment-tools/sessions/977f6cf8-4ba4-4620-9428-11ec4288203f Co-authored-by: joeloff <7409981+joeloff@users.noreply.github.com> --- src/Microsoft.Deployment.DotNet.Releases/src/Utils.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.Deployment.DotNet.Releases/src/Utils.cs b/src/Microsoft.Deployment.DotNet.Releases/src/Utils.cs index 88076ab524..45384dbfb2 100644 --- a/src/Microsoft.Deployment.DotNet.Releases/src/Utils.cs +++ b/src/Microsoft.Deployment.DotNet.Releases/src/Utils.cs @@ -27,8 +27,8 @@ internal class Utils /// if the local file is the latest; otherwise. internal static async Task IsLatestFileAsync(string fileName, Uri address) { - var httpRequest = new HttpRequestMessage(HttpMethod.Head, address); - HttpResponseMessage httpResponse = await s_httpClient.SendAsync(httpRequest).ConfigureAwait(false); + using var httpRequest = new HttpRequestMessage(HttpMethod.Head, address); + using HttpResponseMessage httpResponse = await s_httpClient.SendAsync(httpRequest).ConfigureAwait(false); httpResponse.EnsureSuccessStatusCode(); @@ -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); From feef0404ca33277c76109d9440d5a7818870162c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 6 May 2026 22:54:22 +0000 Subject: [PATCH 3/6] Adjust Utils HEAD request handling per review feedback Agent-Logs-Url: https://github.com/dotnet/deployment-tools/sessions/977f6cf8-4ba4-4620-9428-11ec4288203f Co-authored-by: joeloff <7409981+joeloff@users.noreply.github.com> --- src/Microsoft.Deployment.DotNet.Releases/src/Utils.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.Deployment.DotNet.Releases/src/Utils.cs b/src/Microsoft.Deployment.DotNet.Releases/src/Utils.cs index 45384dbfb2..fd0bd114e8 100644 --- a/src/Microsoft.Deployment.DotNet.Releases/src/Utils.cs +++ b/src/Microsoft.Deployment.DotNet.Releases/src/Utils.cs @@ -27,7 +27,7 @@ internal class Utils /// if the local file is the latest; otherwise. internal static async Task IsLatestFileAsync(string fileName, Uri address) { - using var httpRequest = new HttpRequestMessage(HttpMethod.Head, address); + var httpRequest = new HttpRequestMessage(HttpMethod.Head, address); using HttpResponseMessage httpResponse = await s_httpClient.SendAsync(httpRequest).ConfigureAwait(false); httpResponse.EnsureSuccessStatusCode(); From dfb60ecd4c829bce46f310b9dd4e8eb157dbb0eb Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 7 May 2026 15:46:46 +0000 Subject: [PATCH 4/6] Configure SocketsHttpHandler pooled connection lifetime Agent-Logs-Url: https://github.com/dotnet/deployment-tools/sessions/5ed64a4b-574e-48be-947e-6872f6cdf4e5 Co-authored-by: joeloff <7409981+joeloff@users.noreply.github.com> --- src/Microsoft.Deployment.DotNet.Releases/src/Utils.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.Deployment.DotNet.Releases/src/Utils.cs b/src/Microsoft.Deployment.DotNet.Releases/src/Utils.cs index fd0bd114e8..15bbc7cee3 100644 --- a/src/Microsoft.Deployment.DotNet.Releases/src/Utils.cs +++ b/src/Microsoft.Deployment.DotNet.Releases/src/Utils.cs @@ -149,7 +149,12 @@ internal static async Task GetLatestFileAsync(string path, bool downloadLatest, static Utils() { - s_httpClient = new HttpClient(); + var handler = new SocketsHttpHandler + { + PooledConnectionLifetime = TimeSpan.FromMinutes(2) + }; + + s_httpClient = new HttpClient(handler, disposeHandler: true); s_httpClient.DefaultRequestHeaders.CacheControl = new CacheControlHeaderValue { NoCache = true From f8dbdfc230897ac6e785a424d432937654d7709d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 8 May 2026 04:32:49 +0000 Subject: [PATCH 5/6] Revert SocketsHttpHandler for netstandard2.0 compatibility Agent-Logs-Url: https://github.com/dotnet/deployment-tools/sessions/0cde6492-cd04-4176-8cd1-b0836ad440f1 Co-authored-by: joeloff <7409981+joeloff@users.noreply.github.com> --- src/Microsoft.Deployment.DotNet.Releases/src/Utils.cs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/Microsoft.Deployment.DotNet.Releases/src/Utils.cs b/src/Microsoft.Deployment.DotNet.Releases/src/Utils.cs index 15bbc7cee3..fd0bd114e8 100644 --- a/src/Microsoft.Deployment.DotNet.Releases/src/Utils.cs +++ b/src/Microsoft.Deployment.DotNet.Releases/src/Utils.cs @@ -149,12 +149,7 @@ internal static async Task GetLatestFileAsync(string path, bool downloadLatest, static Utils() { - var handler = new SocketsHttpHandler - { - PooledConnectionLifetime = TimeSpan.FromMinutes(2) - }; - - s_httpClient = new HttpClient(handler, disposeHandler: true); + s_httpClient = new HttpClient(); s_httpClient.DefaultRequestHeaders.CacheControl = new CacheControlHeaderValue { NoCache = true From 74ee413d60d623da16f50ac3621345d6bd43fee8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 8 May 2026 04:35:45 +0000 Subject: [PATCH 6/6] Use HttpClientHandler with explicit disposal in Utils Agent-Logs-Url: https://github.com/dotnet/deployment-tools/sessions/0cde6492-cd04-4176-8cd1-b0836ad440f1 Co-authored-by: joeloff <7409981+joeloff@users.noreply.github.com> --- src/Microsoft.Deployment.DotNet.Releases/src/Utils.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.Deployment.DotNet.Releases/src/Utils.cs b/src/Microsoft.Deployment.DotNet.Releases/src/Utils.cs index fd0bd114e8..63b4900387 100644 --- a/src/Microsoft.Deployment.DotNet.Releases/src/Utils.cs +++ b/src/Microsoft.Deployment.DotNet.Releases/src/Utils.cs @@ -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