FormatException thrown when a content-type with parameters is used. Error occurs with in "CreateHttpRequestMessage" where the content-type header is added.
Minimal repro of the code path:
using System.Net.Http.Headers;
using System.Net.Mime;
var requestMessage = new HttpRequestMessage();
requestMessage.Content = new StreamContent(new MemoryStream());
var contentType = "application/cloudevents+json; charset=utf-8";
requestMessage.Content.Headers.ContentType = new MediaTypeHeaderValue(contentType);
If you drop the "charset" clause, it succeeds. The use of the MediaTypeHeaderValue constructor is incorrect here because it requires a media type as input and not a content-type.
FormatException thrown when a content-type with parameters is used. Error occurs with in "CreateHttpRequestMessage" where the content-type header is added.
Minimal repro of the code path:
If you drop the "charset" clause, it succeeds. The use of the MediaTypeHeaderValue constructor is incorrect here because it requires a media type as input and not a content-type.