cloudevents / cloudevents/sdk-csharp
Make datacontenttype value check case-insensitive
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 334
- Forks
- 88
- Avg merge
- 7m
- Merged PRs (30d)
- 2
Description
SDK is using case-sensitive checks when formatting CloudEvents to Json based on "datacontenttype" value. MIME types type and subtype are case insensitive according to the spec.
For example, this code snippet throws exception:
System.ArgumentException: 'JsonEventFormatter cannot serialize data of type System.String with content type 'application/JSON''
CloudEvent cloudEvent = new CloudEvent
{
Id = "event-id",
Type = "event-type",
Source = new Uri("https://cloudevents.io/"),
Time = DateTimeOffset.UtcNow,
DataContentType = "application/JSON",
Data = "text"
};
CloudEventFormatter formatter = new JsonEventFormatter();
var httpContent = cloudEvent.ToHttpContent(ContentMode.Structured, formatter);
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with JsonEventFormatter and the CloudEvent.DataContentType handling described in the report, then reproduce the application/JSON example. Trace the formatting path and verify that MIME type and subtype comparisons are case-insensitive; done means the example serializes successfully without changing unrelated content types.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100