Skip to content

[Feature Request] Use HTTP 2.0 protocol #5209

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

Open
sherlock1982 opened this issue Mar 27, 2025 · 5 comments · May be fixed by #5210
Open

[Feature Request] Use HTTP 2.0 protocol #5209

sherlock1982 opened this issue Mar 27, 2025 · 5 comments · May be fixed by #5210
Labels
needs attention Delete label after triage untriaged Do not delete. Needed for Automation

Comments

@sherlock1982
Copy link

sherlock1982 commented Mar 27, 2025

MSAL client type

Confidential

Problem statement

HttpManager internally creates HttpRequestMessage which by default uses HTTP 1.1
Ideally should use HTTP 2.0
Even though my factory makes HTTP 2.0 default it won't work

Proposed solution

        private static HttpRequestMessage CreateRequestMessage(Uri endpoint, IDictionary<string, string> headers)
        {
            HttpRequestMessage requestMessage = new HttpRequestMessage { RequestUri = endpoint };
            requestMessage.Version = HttpVersion.Version20;
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            requestMessage.Headers.Accept.Clear();
            if (headers != null)
            {
                foreach (KeyValuePair<string, string> kvp in headers)
                {
                    requestMessage.Headers.Add(kvp.Key, kvp.Value);
                }
            }

            return requestMessage;
        }

Alternatives

Keep using HTTP 1.1

@sherlock1982 sherlock1982 added needs attention Delete label after triage untriaged Do not delete. Needed for Automation labels Mar 27, 2025
@sherlock1982 sherlock1982 linked a pull request Mar 27, 2025 that will close this issue
@bgavrilMS
Copy link
Member

@MZOLN - any thoughts on this?

@bgavrilMS
Copy link
Member

I had a look at this and it looks like the default version is 2 for programs written in .NET and 1.1 for .NET FWK.

https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httprequestmessage.version?view=net-9.0&devlangs=csharp&f1url=%3FappId%3DDev17IDEF1%26l%3DEN-US%26k%3Dk(System.Net.Http.HttpRequestMessage.Version)%3Bk(SolutionItemsProject)%3Bk(DevLang-csharp)%26rd%3Dtrue

As such, it seems that the better option would be to migrate the app to .NET

@sherlock1982
Copy link
Author

sherlock1982 commented May 4, 2025

It is 2.0 only for netcore 2.2 and 2.1. Otherwise it is still 1.1. For example in net8 it is still 1.1.

I think it is up to the library author to decide. BTW Google API client has the same issue.

You can say that it’s probably not that important to have 2.0 when getting a token as you won’t do it in parallel but that depends.

@sherlock1982
Copy link
Author

I could probably intercept it in HttpClient and modify to become 2.0 as a workaround but overall of endpoint supports it why 1.1 ?

@bgavrilMS
Copy link
Member

MSAL needs to talk to other identity providers, for example ADFS (on-prem AD) and 2.0 might not work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs attention Delete label after triage untriaged Do not delete. Needed for Automation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants