Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding HttpHeader.Common.FormUrlEncodedContentType fixes #6646 #6648

Merged
merged 3 commits into from
Jun 20, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions sdk/core/Azure.Core/src/Pipeline/HttpHeader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It wopuld be better if the name of the string and the header were similar.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, fixed.


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);
}
}
}
5 changes: 3 additions & 2 deletions sdk/identity/Azure.Identity/src/IdentityClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand All @@ -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;

Expand Down