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

HttpClient.DefaultRequestHeaders.Add('X-Request-Id', "...") difference between .NET Framework and .NET Core #53699

Closed
vsfeedback opened this issue Jun 3, 2021 · 2 comments

Comments

@vsfeedback
Copy link

vsfeedback commented Jun 3, 2021

This issue has been moved from a ticket on Developer Community.


Here's an example to reproduce the problem:

HttpClient client = new HttpClient();
var reuqestId = Guid.NewGuid();
client. DefaultRequestHeaders.Add("X-Request-Id", reuqestId.ToString());

In .NET Framework, the result of test is:

Bb4265a7992364f4ab1533e53bb754885637538798104237677_1

But in .NET Core (including . NET 5), 'Id' becomes 'ID':

B7a5a4c7bb9024fcdbb464a8c69409c7b637538800662076541_2

I want to know what makes the difference. Is there any way to prevent ‘id’ become 'ID'?


Original Comments

Feedback Bot on 4/13/2021, 03:51 AM:

Thank you for taking the time to provide your suggestion. We will do some preliminary checks to make sure we can proceed further. We'll provide an update once the issue has been triaged by the product team.

@dotnet-issue-labeler dotnet-issue-labeler bot added area-System.Net untriaged New issue has not been triaged by the area owner labels Jun 3, 2021
@ghost
Copy link

ghost commented Jun 3, 2021

Tagging subscribers to this area: @dotnet/ncl
See info in area-owners.md if you want to be subscribed.

Issue Details

This issue has been moved from a ticket on Developer Community.


Here's an example to reproduce the problem:

            HttpClient client = new HttpClient();
            var reuqestId = Guid.NewGuid();
            client. DefaultRequestHeaders.Add("X-Request-Id", reuqestId.ToString());

In .NET Framework, the result of test is :
! [1.png] (https://aka.ms/dc/image?name=Bb4265a7992364f4ab1533e53bb754885637538798104237677_1.png&tid=b4265a7992364f4ab1533e53bb754885637538798104237677)
But in .NET Core(including . NET5), 'Id' becomes 'ID':
! [2.png] (https://aka.ms/dc/image?name=B7a5a4c7bb9024fcdbb464a8c69409c7b637538800662076541_2.png&tid=7a5a4c7bb9024fcdbb464a8c69409c7b637538800662076541)
I want to know what makes the difference.
Is there any way to prevent ‘id’ become 'ID'?


Original Comments

Feedback Bot on 4/13/2021, 03:51 AM:

Thank you for taking the time to provide your suggestion. We will do some preliminary checks to make sure we can proceed further. We'll provide an update once the issue has been triaged by the product team.

Author: vsfeedback
Assignees: -
Labels:

area-System.Net, untriaged

Milestone: -

@MihaZupan
Copy link
Member

MihaZupan commented Jun 3, 2021

X-Request-ID is a known header internally, so we use a cached value of the name.
As per RFC, the name should be considered as case-insensitive.

Closing as a duplicate of #50325. That one is about TryAddWithoutValidation instead of Add, but the cause of the behaviour is the same.

@MihaZupan MihaZupan added this to the 6.0.0 milestone Jun 3, 2021
@MihaZupan MihaZupan added area-System.Net.Http and removed untriaged New issue has not been triaged by the area owner area-System.Net labels Jun 3, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Jul 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants