-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Description
Description
I am using .Net 5 right now, and I am trying to send a request to an API.
I am setting the User Agent using the TryAddWithoutValidation method since I need to use a non compliant User Agent like "My App / 1.0.5" (with the spaces).
Yet when I check the request on Fiddler I see that .Net removes my spaces between App and / and / and 1.0.5.
var requestMessage = new HttpRequestMessage(HttpMethod.Get, "https://test.com");
requestMessage.Headers.TryAddWithoutValidation("User-Agent", "My Android App / 1.0.5");And you will see in Fiddler it appears as User-Agent: "My Android App/1.0.5" (without the spaces) causing a 500 error in my case.
I thought the whole idea of TryAddWithoutValidation was that it would leave my string values alone and just send what I told it to send.
Configuration
.net 5.0 in Windows 10 x64
Regression?
As far as I know this seems to be a recurrent issue in .net core: #35335
#21131
Other information
I have tried using ParseAdd of the UserAgent, and using the default headers of the HttpClient object, all the same result. My user agent gets parsed and transformed. Any help would be appreciated since I cannot communicate with the API unless this gets fixed.