Closed
Description
Description
I currently use ActivitySource and set some data in a baggage that i then use in a custom httpHandler. Everything is fine and all.
but when i add some baggage i get sometime this format error:
System.FormatException: The format of value 'MyApp%2F2022.1.0a5+(Windows%3B+U%3B+Windows+NT+10.0%3B+en)' is invalid.
at System.Net.Http.Headers.NameValueHeaderValue.CheckValueFormat(String value) in /_/src/libraries/System.Net.Http/src/System/Net/Http/Headers/NameValueHeaderValue.cs:line 359
at System.Net.Http.DiagnosticsHandler.InjectHeaders(Activity currentActivity, HttpRequestMessage request) in /_/src/libraries/System.Net.Http/src/System/Net/Http/DiagnosticsHandler.cs:line 315
at System.Net.Http.DiagnosticsHandler.SendAsyncCore(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) in /_/src/libraries/System.Net.Http/src/System/Net/Http/DiagnosticsHandler.cs:line 74
it turn out that by default on httpClient there is an Handler DiagnosticHandler
that is added then this one fail while trying to create an Request-Context
public HttpClientHandler()
{
this._underlyingHandler = new SocketsHttpHandler();
if (DiagnosticsHandler.IsGloballyEnabled())
this._diagnosticsHandler = new DiagnosticsHandler((HttpMessageHandler) this._underlyingHandler);
this.ClientCertificateOptions = ClientCertificateOption.Manual;
}
And in that handler it does what was merge here i think: https://github.com/dotnet/corefx/pull/36203/files
baggage.Append(WebUtility.UrlEncode(item.Key)).Append('=').Append(WebUtility.UrlEncode(item.Value)).Append(',');
How can i turn this thing off or what should i do to my baggage data to prevent it to explose at the next http request ?