Skip to content

fix(core): match event media types case-insensitively - #765

Merged
Cali0707 merged 1 commit into
cloudevents:mainfrom
yangjj-iso:fix-content-type-case
Nov 12, 2026
Merged

Cali0707 merged 1 commit into
cloudevents:mainfrom
yangjj-iso:fix-content-type-case

Conversation

@yangjj-iso

Copy link
Copy Markdown
Contributor

Fixes #764.

Mixed-case structured content types are not recognized by EventFormatProvider. A request with Content-Type: Application/CloudEvents+JSON can therefore be rejected or incorrectly routed through the binary reader when ce-specversion is also present.

Normalize type/subtype keys with Locale.ROOT during registration and lookup, preserving parameter values. Make the unsupported CloudEvents prefix check case-insensitive as well, so capitalization does not change the existing rejection behavior. This follows the HTTP binding §3; event data and header values are unchanged.

Regression coverage exercises mixed-case lookup and registration, unsupported content types, and structured reads through HttpMessageFactory, including parameters and a ce-specversion header.

Validation on Temurin 21 / Maven wrapper:

  • Original implementation: seven selected core cases and two HTTP cases fail; the lowercase HTTP control passes.
  • Final implementation: ./mvnw -pl http/basic -am verify passes all 144 tests (API 8, core 97, HTTP 39), with no failures or skips. Javadoc generation also completes for all three modules.
  • git diff --check passes.
  • Full-repository tests were not run.

AI assistance was used for investigation, implementation, and validation.

Normalize media type keys with Locale.ROOT when registering and resolving
formats, while retaining parameter values. Match unsupported CloudEvents
media type prefixes consistently across case variants.

Add registry, routing, and public HTTP reader regression coverage.

Fixes cloudevents#764

Signed-off-by: redyyang <3202137046@qq.com>
@duglin
duglin force-pushed the fix-content-type-case branch from f8184c9 to 29fb2d6 Compare November 12, 2026 16:30
@duglin

duglin commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

LGTM
@Cali0707 ?

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the case-insensitive CloudEvents media-type matching change.

No open issues 🎉

What changed in this PR

Fixes #764 by making CloudEvents media-type matching case-insensitive, so mixed-case structured HTTP messages are recognized rather than rejected or routed to the binary reader.

Changes:

  • Normalize registered and looked-up type/subtype keys with Locale.ROOT, without lowercasing parameter values.
  • Make unsupported CloudEvents media-type prefix detection case-insensitive.
  • Add regression coverage for mixed-case registration, lookup, rejection, and structured HTTP reads.
File Description
http/​basic/​src/​test/​java/​io/​cloudevents/​http/​HttpMessageReaderWriterTest.java Tests structured reads with mixed-case content types, parameters, and ce-specversion.
core/​src/​test/​java/​io/​cloudevents/​core/​provider/​EventFormatProviderTest.java Tests mixed-case format lookup and registration.
core/​src/​test/​java/​io/​cloudevents/​core/​message/​impl/​MessageUtilsTest.java Tests rejection of mixed-case unsupported CloudEvents types.
core/​src/​main/​java/​io/​cloudevents/​core/​provider/​EventFormatProvider.java Normalizes media-type keys for case-insensitive matching.
core/​src/​main/​java/​io/​cloudevents/​core/​message/​impl/​MessageUtils.java Checks the unsupported CloudEvents prefix case-insensitively.

Review effort: Balanced

@Cali0707
Cali0707 merged commit 652a977 into cloudevents:main Nov 12, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Structured CloudEvents media types are matched case-sensitively

4 participants