From d951f1a0aba8cc0720129f8a85846b4a713e9328 Mon Sep 17 00:00:00 2001
From: CarloToso <105941898+CarloToso@users.noreply.github.com>
Date: Wed, 1 Mar 2023 12:33:34 +0100
Subject: [PATCH 1/4] remove wrong comment
---
.../utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs | 2 --
1 file changed, 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..bebee4bbcb0 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
@@ -904,8 +904,6 @@ internal virtual void PrepareSession()
}
else if (ProxyUseDefaultCredentials)
{
- // If both ProxyCredential and ProxyUseDefaultCredentials are passed,
- // UseDefaultCredentials will overwrite the supplied credentials.
webProxy.UseDefaultCredentials = true;
}
From b12674d38a525c7b286cbc6b2df1da8c4640c732 Mon Sep 17 00:00:00 2001
From: CarloToso <105941898+CarloToso@users.noreply.github.com>
Date: Wed, 1 Mar 2023 14:11:36 +0100
Subject: [PATCH 2/4] conditional ContentLength
---
.../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 bebee4bbcb0..17eb9db9165 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 1df8efe6bc51c4e162d4d5f897f4800ff64a5fe0 Mon Sep 17 00:00:00 2001
From: CarloToso <105941898+CarloToso@users.noreply.github.com>
Date: Wed, 1 Mar 2023 14:55:49 +0100
Subject: [PATCH 3/4] revert
---
.../utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs | 3 +--
.../resources/WebCmdletStrings.resx | 2 +-
2 files 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 17eb9db9165..bebee4bbcb0 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,12 +551,11 @@ 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,
+ response.Content.Headers.ContentLength,
contentType);
WriteVerbose(respVerboseMsg);
diff --git a/src/Microsoft.PowerShell.Commands.Utility/resources/WebCmdletStrings.resx b/src/Microsoft.PowerShell.Commands.Utility/resources/WebCmdletStrings.resx
index d8fb0b2e195..a9628c647e3 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}response of content type {1}
+ received {0}-byte response of content type {1}
Retrying after interval of {0} seconds. Status code for previous attempt: {1}
From da3d5c3d2f9d2a6e5d4dcbc8b2a46e4f44ead1a6 Mon Sep 17 00:00:00 2001
From: CarloToso <105941898+CarloToso@users.noreply.github.com>
Date: Wed, 1 Mar 2023 16:04:00 +0100
Subject: [PATCH 4/4] follow suggestion
---
.../utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs | 4 ++--
1 file changed, 2 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 bebee4bbcb0..69be66e8b5c 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
@@ -902,9 +902,9 @@ internal virtual void PrepareSession()
{
webProxy.Credentials = ProxyCredential.GetNetworkCredential();
}
- else if (ProxyUseDefaultCredentials)
+ else
{
- webProxy.UseDefaultCredentials = true;
+ webProxy.UseDefaultCredentials = ProxyUseDefaultCredentials;
}
WebSession.Proxy = webProxy;