HttpHeaders.TryAddWithoutValidation different behaviour between .net 6 and .net 7/8 #111065
Labels
area-System.Net.Http
needs-author-action
An issue or pull request that requires more info or actions from the author.
untriaged
New issue has not been triaged by the area owner
Description
HttpHeaders.TryAddWithoutValidation different behaviour between .net 6 and .net 7/8.
Reproduction Steps
Create simple console application:
If you create this application in .net 6 you will receive result:
Content-Type: application/json, text/plain; charset=utf-8
application/json
will be first and separated from defaulttext/plain; charset=utf-8
by a coma.In .net 7 or .net 8 you will receive:
Content-Type: text/plain; charset=utf-8, application/json
application/json
is last.This creates problems because later when we are sending
HttpRequestMessage
onlytext/plain
is sent and we receive415 Unsupported Media Type
response.Expected behavior
Results from .net 6 would be expected.
Actual behavior
Results from .net 8.
Regression?
No response
Known Workarounds
Check if you already have header before you use
TryAddWithoutValidation
Configuration
No response
Other information
No response
The text was updated successfully, but these errors were encountered: