From 4cbafea8e280f25def0f99fbfa096c2e27f91012 Mon Sep 17 00:00:00 2001 From: Yabo Hu Date: Wed, 12 Aug 2020 15:21:03 +0800 Subject: [PATCH 1/6] Update ISendAsync.cs pass only Authorization to next header for long running operations. --- powershell/resources/runtime/csharp/pipeline/ISendAsync.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/powershell/resources/runtime/csharp/pipeline/ISendAsync.cs b/powershell/resources/runtime/csharp/pipeline/ISendAsync.cs index 98696e712e..2e9eb89db3 100644 --- a/powershell/resources/runtime/csharp/pipeline/ISendAsync.cs +++ b/powershell/resources/runtime/csharp/pipeline/ISendAsync.cs @@ -255,7 +255,8 @@ internal static HttpRequestMessage Clone(this HttpRequestMessage original, Syste foreach (KeyValuePair> header in original.Headers) { - clone.Headers.TryAddWithoutValidation(header.Key, header.Value); + var authorization = original.Headers.First(x => System.Net.HttpRequestHeader.Authorization.ToString().Equals(x.Key)); + clone.Headers.TryAddWithoutValidation(authorization.Key, authorization.Value); } return clone; @@ -286,4 +287,4 @@ internal static async Task CloneWithContent(this HttpRequest return clone; } } -} \ No newline at end of file +} From 739bd1a7d61ff18abded86a98f29dc5612ee119b Mon Sep 17 00:00:00 2001 From: Yabo Hu Date: Wed, 12 Aug 2020 15:23:26 +0800 Subject: [PATCH 2/6] Update ISendAsync.cs From ad351985f359698a30088b412035ac91b6486ae7 Mon Sep 17 00:00:00 2001 From: Yabo Hu Date: Thu, 13 Aug 2020 09:25:49 +0800 Subject: [PATCH 3/6] Update ISendAsync.cs fix potential null reference --- powershell/resources/runtime/csharp/pipeline/ISendAsync.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/powershell/resources/runtime/csharp/pipeline/ISendAsync.cs b/powershell/resources/runtime/csharp/pipeline/ISendAsync.cs index 2e9eb89db3..d915dfc823 100644 --- a/powershell/resources/runtime/csharp/pipeline/ISendAsync.cs +++ b/powershell/resources/runtime/csharp/pipeline/ISendAsync.cs @@ -253,12 +253,12 @@ internal static HttpRequestMessage Clone(this HttpRequestMessage original, Syste clone.Properties.Add(prop); } - foreach (KeyValuePair> header in original.Headers) + var authorization = original.Headers.First(x => System.Net.HttpRequestHeader.Authorization.ToString().Equals(x.Key)); + if (authorization != null) { - var authorization = original.Headers.First(x => System.Net.HttpRequestHeader.Authorization.ToString().Equals(x.Key)); clone.Headers.TryAddWithoutValidation(authorization.Key, authorization.Value); } - + return clone; } From bd8074089340eb0bac21d2d8bbb4e5c549bbfc39 Mon Sep 17 00:00:00 2001 From: Yabo Hu Date: Thu, 13 Aug 2020 10:12:46 +0800 Subject: [PATCH 4/6] Update ISendAsync.cs --- powershell/resources/runtime/csharp/pipeline/ISendAsync.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/powershell/resources/runtime/csharp/pipeline/ISendAsync.cs b/powershell/resources/runtime/csharp/pipeline/ISendAsync.cs index d915dfc823..afeed71697 100644 --- a/powershell/resources/runtime/csharp/pipeline/ISendAsync.cs +++ b/powershell/resources/runtime/csharp/pipeline/ISendAsync.cs @@ -253,10 +253,10 @@ internal static HttpRequestMessage Clone(this HttpRequestMessage original, Syste clone.Properties.Add(prop); } - var authorization = original.Headers.First(x => System.Net.HttpRequestHeader.Authorization.ToString().Equals(x.Key)); - if (authorization != null) + var authorization = System.Net.HttpRequestHeader.Authorization.ToString(); + if (original.Headers.Contains(authorization)) { - clone.Headers.TryAddWithoutValidation(authorization.Key, authorization.Value); + clone.Headers.TryAddWithoutValidation(authorization, original.Headers.GetValues(authorization)); } return clone; From f03cafa414b1a3e90f2783133ab7b209dcdf7fc9 Mon Sep 17 00:00:00 2001 From: Yabo Hu Date: Thu, 13 Aug 2020 14:16:58 +0800 Subject: [PATCH 5/6] Update ISendAsync.cs --- .../runtime/csharp/pipeline/ISendAsync.cs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/powershell/resources/runtime/csharp/pipeline/ISendAsync.cs b/powershell/resources/runtime/csharp/pipeline/ISendAsync.cs index afeed71697..1c2f556404 100644 --- a/powershell/resources/runtime/csharp/pipeline/ISendAsync.cs +++ b/powershell/resources/runtime/csharp/pipeline/ISendAsync.cs @@ -252,11 +252,17 @@ internal static HttpRequestMessage Clone(this HttpRequestMessage original, Syste { clone.Properties.Add(prop); } - - var authorization = System.Net.HttpRequestHeader.Authorization.ToString(); - if (original.Headers.Contains(authorization)) - { - clone.Headers.TryAddWithoutValidation(authorization, original.Headers.GetValues(authorization)); + + foreach (KeyValuePair> header in original.Headers) + { + /* + **temporarily skip cloning telemetry related headers** + clone.Headers.TryAddWithoutValidation(header.Key, header.Value); + */ + if (!"x-ms-unique-id".Equals(header.Key) || !"x-ms-client-request-id".Equals(header.Key) || !"CommandName".Equals(header.Key) || !"FullCommandName".Equals(header.Key) || !"ParameterSetName".Equals(header.Key) || !"User-Agent".Equals(header.Key)) + { + clone.Headers.TryAddWithoutValidation(header.Key, header.Value); + } } return clone; From 5ca60e90cab6fb6a0054dbdabcb9f357933f38eb Mon Sep 17 00:00:00 2001 From: Yabo Hu Date: Thu, 13 Aug 2020 15:31:14 +0800 Subject: [PATCH 6/6] Update ISendAsync.cs --- powershell/resources/runtime/csharp/pipeline/ISendAsync.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/powershell/resources/runtime/csharp/pipeline/ISendAsync.cs b/powershell/resources/runtime/csharp/pipeline/ISendAsync.cs index 1c2f556404..fb0cc28b94 100644 --- a/powershell/resources/runtime/csharp/pipeline/ISendAsync.cs +++ b/powershell/resources/runtime/csharp/pipeline/ISendAsync.cs @@ -259,7 +259,7 @@ internal static HttpRequestMessage Clone(this HttpRequestMessage original, Syste **temporarily skip cloning telemetry related headers** clone.Headers.TryAddWithoutValidation(header.Key, header.Value); */ - if (!"x-ms-unique-id".Equals(header.Key) || !"x-ms-client-request-id".Equals(header.Key) || !"CommandName".Equals(header.Key) || !"FullCommandName".Equals(header.Key) || !"ParameterSetName".Equals(header.Key) || !"User-Agent".Equals(header.Key)) + if (!"x-ms-unique-id".Equals(header.Key) && !"x-ms-client-request-id".Equals(header.Key) && !"CommandName".Equals(header.Key) && !"FullCommandName".Equals(header.Key) && !"ParameterSetName".Equals(header.Key) && !"User-Agent".Equals(header.Key)) { clone.Headers.TryAddWithoutValidation(header.Key, header.Value); }