From 6b73a8c317deae04dc50a8c4347a2c11cd6d874f Mon Sep 17 00:00:00 2001 From: Scott Schaab Date: Wed, 19 Jun 2019 15:31:12 -0700 Subject: [PATCH 1/3] Adding HttpHeader.Common.FormUrlEncodedContentType fixes #6646 --- sdk/core/Azure.Core/src/Pipeline/HttpHeader.cs | 2 ++ sdk/identity/Azure.Identity/src/IdentityClient.cs | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/sdk/core/Azure.Core/src/Pipeline/HttpHeader.cs b/sdk/core/Azure.Core/src/Pipeline/HttpHeader.cs index 5a90e088c210c..e142886a266a2 100644 --- a/sdk/core/Azure.Core/src/Pipeline/HttpHeader.cs +++ b/sdk/core/Azure.Core/src/Pipeline/HttpHeader.cs @@ -61,10 +61,12 @@ public static class Common { static readonly string s_applicationJson = "application/json"; static readonly string s_applicationOctetStream = "application/octet-stream"; + static readonly string s_applicationForm = "application/x-www-form-urlencoded"; public static readonly HttpHeader JsonContentType = new HttpHeader(Names.ContentType, s_applicationJson); public static readonly HttpHeader JsonAccept = new HttpHeader(Names.Accept, s_applicationJson); public static readonly HttpHeader OctetStreamContentType = new HttpHeader(Names.ContentType, s_applicationOctetStream); + public static readonly HttpHeader FormUrlEncodedContentType = new HttpHeader(Names.ContentType, s_applicationOctetStream); } } } diff --git a/sdk/identity/Azure.Identity/src/IdentityClient.cs b/sdk/identity/Azure.Identity/src/IdentityClient.cs index c61aef85f238f..53bfee83ebecf 100644 --- a/sdk/identity/Azure.Identity/src/IdentityClient.cs +++ b/sdk/identity/Azure.Identity/src/IdentityClient.cs @@ -8,6 +8,7 @@ using System.Buffers; using System.Collections.Generic; using System.IO; +using System.Net.Http; using System.Runtime.CompilerServices; using System.Security.Cryptography; using System.Security.Cryptography.X509Certificates; @@ -171,7 +172,7 @@ private Request CreateClientSecretAuthRequest(string tenantId, string clientId, request.Method = HttpPipelineMethod.Post; - request.Headers.SetValue("Content-Type", "application/x-www-form-urlencoded"); + request.Headers.Add(HttpHeader.Common.FormUrlEncodedContentType); request.UriBuilder.Uri = _options.AuthorityHost; @@ -194,7 +195,7 @@ private Request CreateClientCertificateAuthRequest(string tenantId, string clien request.Method = HttpPipelineMethod.Post; - request.Headers.SetValue("Content-Type", "application/x-www-form-urlencoded"); + request.Headers.Add(HttpHeader.Common.FormUrlEncodedContentType); request.UriBuilder.Uri = _options.AuthorityHost; From 5640e69ead675a5a4b470d57fddf940ec790018c Mon Sep 17 00:00:00 2001 From: Scott Schaab Date: Wed, 19 Jun 2019 15:35:45 -0700 Subject: [PATCH 2/3] fixing copy paste error --- sdk/core/Azure.Core/src/Pipeline/HttpHeader.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/core/Azure.Core/src/Pipeline/HttpHeader.cs b/sdk/core/Azure.Core/src/Pipeline/HttpHeader.cs index e142886a266a2..e6f441848928a 100644 --- a/sdk/core/Azure.Core/src/Pipeline/HttpHeader.cs +++ b/sdk/core/Azure.Core/src/Pipeline/HttpHeader.cs @@ -66,7 +66,7 @@ public static class Common public static readonly HttpHeader JsonContentType = new HttpHeader(Names.ContentType, s_applicationJson); public static readonly HttpHeader JsonAccept = new HttpHeader(Names.Accept, s_applicationJson); public static readonly HttpHeader OctetStreamContentType = new HttpHeader(Names.ContentType, s_applicationOctetStream); - public static readonly HttpHeader FormUrlEncodedContentType = new HttpHeader(Names.ContentType, s_applicationOctetStream); + public static readonly HttpHeader FormUrlEncodedContentType = new HttpHeader(Names.ContentType, s_applicationForm); } } } From cb8fa132e8eb26b9a797216e5f6d18b05440a75d Mon Sep 17 00:00:00 2001 From: Scott Schaab Date: Wed, 19 Jun 2019 16:35:42 -0700 Subject: [PATCH 3/3] updates addressing PR feedback --- sdk/core/Azure.Core/src/Pipeline/HttpHeader.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/core/Azure.Core/src/Pipeline/HttpHeader.cs b/sdk/core/Azure.Core/src/Pipeline/HttpHeader.cs index e6f441848928a..1c88c7214c020 100644 --- a/sdk/core/Azure.Core/src/Pipeline/HttpHeader.cs +++ b/sdk/core/Azure.Core/src/Pipeline/HttpHeader.cs @@ -61,12 +61,12 @@ public static class Common { static readonly string s_applicationJson = "application/json"; static readonly string s_applicationOctetStream = "application/octet-stream"; - static readonly string s_applicationForm = "application/x-www-form-urlencoded"; + static readonly string s_applicationFormUrlEncoded = "application/x-www-form-urlencoded"; public static readonly HttpHeader JsonContentType = new HttpHeader(Names.ContentType, s_applicationJson); public static readonly HttpHeader JsonAccept = new HttpHeader(Names.Accept, s_applicationJson); public static readonly HttpHeader OctetStreamContentType = new HttpHeader(Names.ContentType, s_applicationOctetStream); - public static readonly HttpHeader FormUrlEncodedContentType = new HttpHeader(Names.ContentType, s_applicationForm); + public static readonly HttpHeader FormUrlEncodedContentType = new HttpHeader(Names.ContentType, s_applicationFormUrlEncoded); } } }