diff --git a/sdk/batch/Microsoft.Azure.Batch.Conventions.Files/tests/IntegrationTests/Microsoft.Azure.Batch.Conventions.Files.Integration.Tests.csproj b/sdk/batch/Microsoft.Azure.Batch.Conventions.Files/tests/IntegrationTests/Microsoft.Azure.Batch.Conventions.Files.Integration.Tests.csproj index 076cc17039af1..2bb2f211ea3ec 100644 --- a/sdk/batch/Microsoft.Azure.Batch.Conventions.Files/tests/IntegrationTests/Microsoft.Azure.Batch.Conventions.Files.Integration.Tests.csproj +++ b/sdk/batch/Microsoft.Azure.Batch.Conventions.Files/tests/IntegrationTests/Microsoft.Azure.Batch.Conventions.Files.Integration.Tests.csproj @@ -16,16 +16,6 @@ bin\$(Configuration)\ - - - - - - - - - - Microsoft.Azure.Batch.FileConventions.Integration.Tests Azure Batch File conventions IntegrationTests tests class library diff --git a/sdk/batch/Microsoft.Azure.Batch.Conventions.Files/tests/UnitTests/Microsoft.Azure.Batch.Conventions.Files.Tests.csproj b/sdk/batch/Microsoft.Azure.Batch.Conventions.Files/tests/UnitTests/Microsoft.Azure.Batch.Conventions.Files.Tests.csproj index f3e493ca54a26..1bff51ee3beff 100644 --- a/sdk/batch/Microsoft.Azure.Batch.Conventions.Files/tests/UnitTests/Microsoft.Azure.Batch.Conventions.Files.Tests.csproj +++ b/sdk/batch/Microsoft.Azure.Batch.Conventions.Files/tests/UnitTests/Microsoft.Azure.Batch.Conventions.Files.Tests.csproj @@ -20,13 +20,6 @@ - - - - - - - diff --git a/sdk/batch/Microsoft.Azure.Batch.FileStaging/tests/Microsoft.Azure.Batch.FileStaging.Tests.csproj b/sdk/batch/Microsoft.Azure.Batch.FileStaging/tests/Microsoft.Azure.Batch.FileStaging.Tests.csproj index 554a48d40c223..0feb6f8c01fc6 100644 --- a/sdk/batch/Microsoft.Azure.Batch.FileStaging/tests/Microsoft.Azure.Batch.FileStaging.Tests.csproj +++ b/sdk/batch/Microsoft.Azure.Batch.FileStaging/tests/Microsoft.Azure.Batch.FileStaging.Tests.csproj @@ -12,16 +12,6 @@ true - - - - - - - - - - Microsoft.Azure.Batch.FileStaging.Tests Azure Batch File Staging integration tests diff --git a/sdk/cognitiveservices/FormRecognizer/tests/Microsoft.Azure.CognitiveServices.Vision.FormRecognizer.Tests.csproj b/sdk/cognitiveservices/FormRecognizer/tests/Microsoft.Azure.CognitiveServices.Vision.FormRecognizer.Tests.csproj index 773ece07fac0f..a855d23f7fee6 100644 --- a/sdk/cognitiveservices/FormRecognizer/tests/Microsoft.Azure.CognitiveServices.Vision.FormRecognizer.Tests.csproj +++ b/sdk/cognitiveservices/FormRecognizer/tests/Microsoft.Azure.CognitiveServices.Vision.FormRecognizer.Tests.csproj @@ -8,9 +8,6 @@ - - - diff --git a/sdk/cognitiveservices/Language.LUIS.Authoring/tests/Microsoft.Azure.CognitiveServices.Language.LUIS.Authoring.Tests.csproj b/sdk/cognitiveservices/Language.LUIS.Authoring/tests/Microsoft.Azure.CognitiveServices.Language.LUIS.Authoring.Tests.csproj index c927c79f5c3f9..fa013d98b3e53 100644 --- a/sdk/cognitiveservices/Language.LUIS.Authoring/tests/Microsoft.Azure.CognitiveServices.Language.LUIS.Authoring.Tests.csproj +++ b/sdk/cognitiveservices/Language.LUIS.Authoring/tests/Microsoft.Azure.CognitiveServices.Language.LUIS.Authoring.Tests.csproj @@ -9,9 +9,6 @@ - - - diff --git a/sdk/cognitiveservices/Language.LUIS.Runtime/tests/Microsoft.Azure.CognitiveServices.Language.LUIS.Runtime.Tests.csproj b/sdk/cognitiveservices/Language.LUIS.Runtime/tests/Microsoft.Azure.CognitiveServices.Language.LUIS.Runtime.Tests.csproj index b7fbc28427813..3532528f1235f 100644 --- a/sdk/cognitiveservices/Language.LUIS.Runtime/tests/Microsoft.Azure.CognitiveServices.Language.LUIS.Runtime.Tests.csproj +++ b/sdk/cognitiveservices/Language.LUIS.Runtime/tests/Microsoft.Azure.CognitiveServices.Language.LUIS.Runtime.Tests.csproj @@ -6,13 +6,6 @@ true - - - - - - - $(RequiredTargetFrameworks) diff --git a/sdk/cognitiveservices/Search.BingAutoSuggest/tests/Microsoft.Azure.CognitiveServices.Search.BingAutoSuggest.Tests.csproj b/sdk/cognitiveservices/Search.BingAutoSuggest/tests/Microsoft.Azure.CognitiveServices.Search.BingAutoSuggest.Tests.csproj index e5c216a5957c4..f05b7d54de784 100644 --- a/sdk/cognitiveservices/Search.BingAutoSuggest/tests/Microsoft.Azure.CognitiveServices.Search.BingAutoSuggest.Tests.csproj +++ b/sdk/cognitiveservices/Search.BingAutoSuggest/tests/Microsoft.Azure.CognitiveServices.Search.BingAutoSuggest.Tests.csproj @@ -5,13 +5,6 @@ 1.0.0 true - - - - - - - $(RequiredTargetFrameworks) diff --git a/sdk/core/Azure.Core/src/Pipeline/HttpClientTransport.cs b/sdk/core/Azure.Core/src/Pipeline/HttpClientTransport.cs index c65ada8fd261a..2c3ab3cc88a14 100644 --- a/sdk/core/Azure.Core/src/Pipeline/HttpClientTransport.cs +++ b/sdk/core/Azure.Core/src/Pipeline/HttpClientTransport.cs @@ -207,25 +207,61 @@ private static HttpRequestMessage BuildRequestMessage(HttpMessage message) internal static bool TryGetHeader(HttpHeaders headers, HttpContent? content, string name, [NotNullWhen(true)] out string? value) { +#if NET6_0_OR_GREATER + if (headers.NonValidated.TryGetValues(name, out HeaderStringValues values) || + content is not null && content.Headers.NonValidated.TryGetValues(name, out values)) + { + value = JoinHeaderValues(values); + return true; + } +#else if (TryGetHeader(headers, content, name, out IEnumerable? values)) { value = JoinHeaderValues(values); return true; } - +#endif value = null; return false; } internal static bool TryGetHeader(HttpHeaders headers, HttpContent? content, string name, [NotNullWhen(true)] out IEnumerable? values) { +#if NET6_0_OR_GREATER + if (headers.NonValidated.TryGetValues(name, out HeaderStringValues headerStringValues) || + content != null && + content.Headers.NonValidated.TryGetValues(name, out headerStringValues)) + { + values = headerStringValues; + return true; + } + + values = null; + return false; +#else return headers.TryGetValues(name, out values) || content != null && content.Headers.TryGetValues(name, out values); +#endif + } internal static IEnumerable GetHeaders(HttpHeaders headers, HttpContent? content) { +#if NET6_0_OR_GREATER + foreach (var (key, value) in headers.NonValidated) + { + yield return new HttpHeader(key, JoinHeaderValues(value)); + } + + if (content is not null) + { + foreach (var (key, value) in content.Headers.NonValidated) + { + yield return new HttpHeader(key, JoinHeaderValues(value)); + } + } +#else foreach (KeyValuePair> header in headers) { yield return new HttpHeader(header.Key, JoinHeaderValues(header.Value)); @@ -238,28 +274,43 @@ internal static IEnumerable GetHeaders(HttpHeaders headers, HttpCont yield return new HttpHeader(header.Key, JoinHeaderValues(header.Value)); } } +#endif + } internal static bool RemoveHeader(HttpHeaders headers, HttpContent? content, string name) { // .Remove throws on invalid header name so use TryGet here to check +#if NET6_0_OR_GREATER + if (headers.NonValidated.Contains(name) && headers.Remove(name)) + { + return true; + } + + return content is not null && content.Headers.NonValidated.Contains(name) && content.Headers.Remove(name); +#else if (headers.TryGetValues(name, out _) && headers.Remove(name)) { return true; } return content?.Headers.TryGetValues(name, out _) == true && content.Headers.Remove(name); +#endif } internal static bool ContainsHeader(HttpHeaders headers, HttpContent? content, string name) { // .Contains throws on invalid header name so use TryGet here +#if NET6_0_OR_GREATER + return headers.NonValidated.Contains(name) || content is not null && content.Headers.NonValidated.Contains(name); +#else if (headers.TryGetValues(name, out _)) { return true; } return content?.Headers.TryGetValues(name, out _) == true; +#endif } internal static void CopyHeaders(HttpHeaders from, HttpHeaders to) @@ -272,11 +323,22 @@ internal static void CopyHeaders(HttpHeaders from, HttpHeaders to) } } } - +#if NET6_0_OR_GREATER + private static string JoinHeaderValues(HeaderStringValues values) + { + return values.Count switch + { + 0 => string.Empty, + 1 => values.ToString(), + _ => string.Join(",", values) + }; + } +#else private static string JoinHeaderValues(IEnumerable values) { return string.Join(",", values); } +#endif private sealed class PipelineRequest : Request { diff --git a/sdk/core/Azure.Core/src/Pipeline/HttpPipelineSynchronousPolicy.cs b/sdk/core/Azure.Core/src/Pipeline/HttpPipelineSynchronousPolicy.cs index 6c9c958be7332..e24d9fd75c08d 100644 --- a/sdk/core/Azure.Core/src/Pipeline/HttpPipelineSynchronousPolicy.cs +++ b/sdk/core/Azure.Core/src/Pipeline/HttpPipelineSynchronousPolicy.cs @@ -40,13 +40,6 @@ public override void Process(HttpMessage message, ReadOnlyMemory public override ValueTask ProcessAsync(HttpMessage message, ReadOnlyMemory pipeline) { - async ValueTask ProcessAsyncInner(HttpMessage message, ReadOnlyMemory pipeline) - { - OnSendingRequest(message); - await ProcessNextAsync(message, pipeline).ConfigureAwait(false); - OnReceivedResponse(message); - } - if (!_hasOnReceivedResponse) { // If OnReceivedResponse was not overridden we can avoid creating a state machine and return the task directly @@ -54,7 +47,14 @@ async ValueTask ProcessAsyncInner(HttpMessage message, ReadOnlyMemory pipeline) + { + OnSendingRequest(message); + await ProcessNextAsync(message, pipeline).ConfigureAwait(false); + OnReceivedResponse(message); } /// diff --git a/sdk/core/Azure.Core/tests/TransportFunctionalTests.cs b/sdk/core/Azure.Core/tests/TransportFunctionalTests.cs index 41f23a8df8dfa..0523de9a4f76d 100644 --- a/sdk/core/Azure.Core/tests/TransportFunctionalTests.cs +++ b/sdk/core/Azure.Core/tests/TransportFunctionalTests.cs @@ -370,7 +370,7 @@ public async Task CanGetAndSetResponseHeaders(string headerName, string headerVa Response response = await ExecuteRequest(request, transport); - Assert.True(response.Headers.Contains(headerName)); + Assert.True(response.Headers.Contains(headerName), $"response.Headers contains the following headers: {string.Join(", ", response.Headers.Select(h => $"\"{h.Name}\": \"{h.Value}\""))}"); Assert.True(response.Headers.TryGetValue(headerName, out var value)); Assert.AreEqual(headerValue, value); diff --git a/sdk/storage/Microsoft.Azure.WebJobs.Extensions.Storage.Scenario.Tests/tests/Microsoft.Azure.WebJobs.Extensions.Storage.Scenario.Tests.csproj b/sdk/storage/Microsoft.Azure.WebJobs.Extensions.Storage.Scenario.Tests/tests/Microsoft.Azure.WebJobs.Extensions.Storage.Scenario.Tests.csproj index 4094749d5f5d1..aa7b252fada5e 100644 --- a/sdk/storage/Microsoft.Azure.WebJobs.Extensions.Storage.Scenario.Tests/tests/Microsoft.Azure.WebJobs.Extensions.Storage.Scenario.Tests.csproj +++ b/sdk/storage/Microsoft.Azure.WebJobs.Extensions.Storage.Scenario.Tests/tests/Microsoft.Azure.WebJobs.Extensions.Storage.Scenario.Tests.csproj @@ -9,8 +9,6 @@ - - diff --git a/sdk/storagepool/Azure.ResourceManager.StoragePool/tests/Azure.ResourceManager.StoragePool.Tests.csproj b/sdk/storagepool/Azure.ResourceManager.StoragePool/tests/Azure.ResourceManager.StoragePool.Tests.csproj index 95eed72a5935f..4ba67ba70483c 100644 --- a/sdk/storagepool/Azure.ResourceManager.StoragePool/tests/Azure.ResourceManager.StoragePool.Tests.csproj +++ b/sdk/storagepool/Azure.ResourceManager.StoragePool/tests/Azure.ResourceManager.StoragePool.Tests.csproj @@ -4,7 +4,6 @@ -