From 13c590f8d138d6a30b899a5172cc6ec494db930b Mon Sep 17 00:00:00 2001 From: Mariana Dematte Date: Thu, 10 Apr 2025 21:59:33 +0000 Subject: [PATCH 1/2] Merged PR 627363: [vs17.12] DownloadFile should not rely on the response headers DownloadFile should not rely on the remote server response headers. Unless the DestinationFileName task parameter is specified - let's just fallback to the request URI - which is as well the publicly documented behavior ---- #### AI description (iteration 1) #### PR Classification Bug fix #### PR Summary This pull request updates the `DownloadFile` task to avoid relying on response headers for determining the file name, instead using the request URI. - Changes in `src/Tasks/DownloadFile.cs` to use `requestUri` instead of `response` for file name determination. - Modified method signature and logic in `TryGetFileName` to use `requestUri`. - Updated call to `TryGetFileName` to pass `uri` instead of `response`. --- eng/Versions.props | 2 +- src/Tasks/DownloadFile.cs | 17 ++++++++--------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/eng/Versions.props b/eng/Versions.props index bdebc91d375..29774d4be60 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -2,7 +2,7 @@ - 17.12.34 + 17.12.35 release 17.11.4 15.1.0.0 diff --git a/src/Tasks/DownloadFile.cs b/src/Tasks/DownloadFile.cs index 71dc72e4c91..8c311f45624 100644 --- a/src/Tasks/DownloadFile.cs +++ b/src/Tasks/DownloadFile.cs @@ -169,7 +169,7 @@ private async Task DownloadAsync(Uri uri, CancellationToken cancellationToken) #endif } - if (!TryGetFileName(response, out string filename)) + if (!TryGetFileName(uri, out string filename)) { Log.LogErrorWithCodeFromResources("DownloadFile.ErrorUnknownFileName", SourceUrl, nameof(DestinationFileName)); return; @@ -308,25 +308,24 @@ private static bool IsRetriable(Exception exception, out Exception actualExcepti /// /// Attempts to get the file name to use when downloading the file. /// - /// The with information about the response. + /// The uri we sent request to. /// Receives the name of the file. /// true if a file name could be determined, otherwise false. - private bool TryGetFileName(HttpResponseMessage response, out string filename) + private bool TryGetFileName(Uri requestUri, out string filename) { - if (response == null) + if (requestUri == null) { - throw new ArgumentNullException(nameof(response)); + throw new ArgumentNullException(nameof(requestUri)); } // Not all URIs contain a file name so users will have to specify one // Example: http://www.download.com/file/1/ - filename = !String.IsNullOrWhiteSpace(DestinationFileName?.ItemSpec) + filename = !string.IsNullOrWhiteSpace(DestinationFileName?.ItemSpec) ? DestinationFileName.ItemSpec // Get the file name from what the user specified - : response.Content?.Headers?.ContentDisposition?.FileName // Attempt to get the file name from the content-disposition header value - ?? Path.GetFileName(response.RequestMessage.RequestUri.LocalPath); // Otherwise attempt to get a file name from the URI + : Path.GetFileName(requestUri.LocalPath); // Otherwise attempt to get a file name from the URI - return !String.IsNullOrWhiteSpace(filename); + return !string.IsNullOrWhiteSpace(filename); } #if !NET6_0_OR_GREATER From d1cce8d7cc03c23a4f1bad8e9240714fd9d199a3 Mon Sep 17 00:00:00 2001 From: Mariana Dematte Date: Wed, 23 Apr 2025 12:46:26 +0000 Subject: [PATCH 2/2] Merged PR 630789: [17.12] Version bump We're doing a version bump so all branches have up-to-date opt-prof runs. [OptProf data](https://dev.azure.com/devdiv/_apps/hub/ms-vscs-artifact.build-tasks.drop-hub-group-explorer-hub?name=OptimizationData/DotNet-msbuild-Trusted/vs17.12/20250414.8/11397433/1) ---- #### AI description (iteration 1) #### PR Classification Version bump. #### PR Summary This pull request updates the version number in the project configuration. - `eng/Versions.props`: Bumped `VersionPrefix` from `17.12.35` to `17.12.36`. --- eng/Versions.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/Versions.props b/eng/Versions.props index 29774d4be60..e9462435ebe 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -2,7 +2,7 @@ - 17.12.35 + 17.12.36 release 17.11.4 15.1.0.0