From 92f8af260a99af470373d5908d0565dac1b77800 Mon Sep 17 00:00:00 2001 From: CarloToso <105941898+CarloToso@users.noreply.github.com> Date: Wed, 1 Mar 2023 14:51:33 +0100 Subject: [PATCH 1/7] conditional comment --- .../utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs | 3 ++- .../resources/WebCmdletStrings.resx | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs index 70f03f5ddef..5f47f75037f 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs @@ -551,11 +551,12 @@ protected override void ProcessRecord() using HttpResponseMessage response = GetResponse(client, request, handleRedirect); + string byteLength = response.Content.Headers.ContentLength is null ? string.Empty : $"{response.Content.Headers.ContentLength}-byte "; string contentType = ContentHelper.GetContentType(response); string respVerboseMsg = string.Format( CultureInfo.CurrentCulture, WebCmdletStrings.WebResponseVerboseMsg, - response.Content.Headers.ContentLength, + byteLength, contentType); WriteVerbose(respVerboseMsg); diff --git a/src/Microsoft.PowerShell.Commands.Utility/resources/WebCmdletStrings.resx b/src/Microsoft.PowerShell.Commands.Utility/resources/WebCmdletStrings.resx index a9628c647e3..d8fb0b2e195 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/resources/WebCmdletStrings.resx +++ b/src/Microsoft.PowerShell.Commands.Utility/resources/WebCmdletStrings.resx @@ -238,7 +238,7 @@ The remote server indicated it could not resume downloading. The local file will be overwritten. - received {0}-byte response of content type {1} + received {0}response of content type {1} Retrying after interval of {0} seconds. Status code for previous attempt: {1} From d4df9eabddd23104f9b550be74c3da80616d7501 Mon Sep 17 00:00:00 2001 From: CarloToso <105941898+CarloToso@users.noreply.github.com> Date: Wed, 1 Mar 2023 16:38:24 +0100 Subject: [PATCH 2/7] change comment --- .../WebCmdlet/Common/WebRequestPSCmdlet.Common.cs | 12 +++++------- .../resources/WebCmdletStrings.resx | 5 ++++- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs index 5f47f75037f..f1ee7480851 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs @@ -551,14 +551,12 @@ protected override void ProcessRecord() using HttpResponseMessage response = GetResponse(client, request, handleRedirect); - string byteLength = response.Content.Headers.ContentLength is null ? string.Empty : $"{response.Content.Headers.ContentLength}-byte "; string contentType = ContentHelper.GetContentType(response); - string respVerboseMsg = string.Format( - CultureInfo.CurrentCulture, - WebCmdletStrings.WebResponseVerboseMsg, - byteLength, - contentType); - + long? byteLength = response.Content.Headers.ContentLength ?? null; + string respVerboseMsg = byteLength is null ? + string.Format(CultureInfo.CurrentCulture, WebCmdletStrings.WebResponseVerboseMsgNoSize, contentType) : + string.Format(CultureInfo.CurrentCulture, WebCmdletStrings.WebResponseVerboseMsg, byteLength ,contentType); + WriteVerbose(respVerboseMsg); bool _isSuccess = response.IsSuccessStatusCode; diff --git a/src/Microsoft.PowerShell.Commands.Utility/resources/WebCmdletStrings.resx b/src/Microsoft.PowerShell.Commands.Utility/resources/WebCmdletStrings.resx index d8fb0b2e195..22c25461d47 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/resources/WebCmdletStrings.resx +++ b/src/Microsoft.PowerShell.Commands.Utility/resources/WebCmdletStrings.resx @@ -238,7 +238,10 @@ The remote server indicated it could not resume downloading. The local file will be overwritten. - received {0}response of content type {1} + received {0}-byte response of content type {1} + + + received response of content type {0} of unknown size Retrying after interval of {0} seconds. Status code for previous attempt: {1} From c5dcd26258cd5576a7f7c53b725466000b7767d8 Mon Sep 17 00:00:00 2001 From: CarloToso <105941898+CarloToso@users.noreply.github.com> Date: Wed, 1 Mar 2023 16:52:05 +0100 Subject: [PATCH 3/7] follow suggestion --- .../utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs index f1ee7480851..4662d74ddc7 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs @@ -552,10 +552,9 @@ protected override void ProcessRecord() using HttpResponseMessage response = GetResponse(client, request, handleRedirect); string contentType = ContentHelper.GetContentType(response); - long? byteLength = response.Content.Headers.ContentLength ?? null; - string respVerboseMsg = byteLength is null ? + string respVerboseMsg = response.Content.Headers.ContentLength is null ? string.Format(CultureInfo.CurrentCulture, WebCmdletStrings.WebResponseVerboseMsgNoSize, contentType) : - string.Format(CultureInfo.CurrentCulture, WebCmdletStrings.WebResponseVerboseMsg, byteLength ,contentType); + string.Format(CultureInfo.CurrentCulture, WebCmdletStrings.WebResponseVerboseMsg, response.Content.Headers.ContentLength,contentType); WriteVerbose(respVerboseMsg); From 7d28c6d14b8454417a38009304404bac37f3b97a Mon Sep 17 00:00:00 2001 From: CarloToso <105941898+CarloToso@users.noreply.github.com> Date: Wed, 1 Mar 2023 17:04:46 +0100 Subject: [PATCH 4/7] add space --- .../utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs index 4662d74ddc7..390d82a2f48 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs @@ -554,7 +554,7 @@ protected override void ProcessRecord() string contentType = ContentHelper.GetContentType(response); string respVerboseMsg = response.Content.Headers.ContentLength is null ? string.Format(CultureInfo.CurrentCulture, WebCmdletStrings.WebResponseVerboseMsgNoSize, contentType) : - string.Format(CultureInfo.CurrentCulture, WebCmdletStrings.WebResponseVerboseMsg, response.Content.Headers.ContentLength,contentType); + string.Format(CultureInfo.CurrentCulture, WebCmdletStrings.WebResponseVerboseMsg, response.Content.Headers.ContentLength, contentType); WriteVerbose(respVerboseMsg); From 209c372479a892a2b4a407a7576ae3121f2d37cb Mon Sep 17 00:00:00 2001 From: CarloToso <105941898+CarloToso@users.noreply.github.com> Date: Wed, 1 Mar 2023 23:37:01 +0100 Subject: [PATCH 5/7] Update src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs Co-authored-by: Dongbo Wang --- .../utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs index 390d82a2f48..fa47f5ef4ae 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs @@ -552,9 +552,10 @@ protected override void ProcessRecord() using HttpResponseMessage response = GetResponse(client, request, handleRedirect); string contentType = ContentHelper.GetContentType(response); - string respVerboseMsg = response.Content.Headers.ContentLength is null ? - string.Format(CultureInfo.CurrentCulture, WebCmdletStrings.WebResponseVerboseMsgNoSize, contentType) : - string.Format(CultureInfo.CurrentCulture, WebCmdletStrings.WebResponseVerboseMsg, response.Content.Headers.ContentLength, contentType); + long? contentLength = response.Content.Headers.ContentLength; + string respVerboseMsg = contentLength is null + ? string.Format(CultureInfo.CurrentCulture, WebCmdletStrings.WebResponseVerboseMsgNoSize, contentType) + : string.Format(CultureInfo.CurrentCulture, WebCmdletStrings.WebResponseVerboseMsg, contentLength, contentType); WriteVerbose(respVerboseMsg); From c153040b0518756c91a1ad4c787e41b5363d6f8d Mon Sep 17 00:00:00 2001 From: CarloToso <105941898+CarloToso@users.noreply.github.com> Date: Wed, 1 Mar 2023 23:38:45 +0100 Subject: [PATCH 6/7] update name --- .../utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs index fa47f5ef4ae..66203e6cecd 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs @@ -554,7 +554,7 @@ protected override void ProcessRecord() string contentType = ContentHelper.GetContentType(response); long? contentLength = response.Content.Headers.ContentLength; string respVerboseMsg = contentLength is null - ? string.Format(CultureInfo.CurrentCulture, WebCmdletStrings.WebResponseVerboseMsgNoSize, contentType) + ? string.Format(CultureInfo.CurrentCulture, WebCmdletStrings.WebResponseNoSizeVerboseMsg, contentType) : string.Format(CultureInfo.CurrentCulture, WebCmdletStrings.WebResponseVerboseMsg, contentLength, contentType); WriteVerbose(respVerboseMsg); From 14fd16301079b8c02296de6674aeab08b36f2078 Mon Sep 17 00:00:00 2001 From: CarloToso <105941898+CarloToso@users.noreply.github.com> Date: Wed, 1 Mar 2023 23:39:43 +0100 Subject: [PATCH 7/7] Update src/Microsoft.PowerShell.Commands.Utility/resources/WebCmdletStrings.resx Co-authored-by: Dongbo Wang --- .../resources/WebCmdletStrings.resx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.PowerShell.Commands.Utility/resources/WebCmdletStrings.resx b/src/Microsoft.PowerShell.Commands.Utility/resources/WebCmdletStrings.resx index 22c25461d47..99a1d0ef7c6 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/resources/WebCmdletStrings.resx +++ b/src/Microsoft.PowerShell.Commands.Utility/resources/WebCmdletStrings.resx @@ -240,7 +240,7 @@ received {0}-byte response of content type {1} - + received response of content type {0} of unknown size