Skip to content

Make Content-Type validation robust to MIME parameters and case-insensitive per RFC 9110 - #126

Merged
tomdesair merged 1 commit into
masterfrom
bugfix/robust-content-type-validation
Aug 29, 2026
Merged

Make Content-Type validation robust to MIME parameters and case-insensitive per RFC 9110#126
tomdesair merged 1 commit into
masterfrom
bugfix/robust-content-type-validation

Conversation

@tomdesair

Copy link
Copy Markdown
Owner

Summary

  • Add Utils.isMediaType(String contentTypeHeader, String expectedMediaType) and Utils.extractMediaType(String contentTypeHeader) to parse HTTP media types per RFC 9110 §8.3 (stripping parameters such as ;charset=UTF-8 and performing case-insensitive matching).
  • Define HttpHeader.CONTENT_TYPE_OFFSET_OCTET_STREAM constant.
  • Update ContentTypeValidator, PostContentTypeValidator, RufhAppendValidator, and protocol version autodetection in Utils to use Utils.isMediaType(...) and the HttpHeader constant.
  • Add unit tests covering charset parameters, whitespace variations, and mixed casing across UtilsTest, ContentTypeValidatorTest, and PostContentTypeValidatorTest (100% diff code coverage).

@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 94.62% (+0.04%) from 94.583% — bugfix/robust-content-type-validation into master

@tomdesair
tomdesair merged commit 0444015 into master Aug 29, 2026
13 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.

2 participants