Skip to content

fix: serve JavaScript files as text/javascript - #1522

Merged
He-Pin merged 1 commit into
apache:mainfrom
He-Pin:fix/javascript-media-type
Nov 20, 2026
Merged

He-Pin merged 1 commit into
apache:mainfrom
He-Pin:fix/javascript-media-type

Conversation

@He-Pin

@He-Pin He-Pin commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

Motivation

RFC 9239 identifies text/javascript as the preferred media type for
JavaScript, but the default filename lookup chooses application/javascript.

Modification

Register text/javascript for .js and .mjs in the Scala and Java models.
Keep application/javascript available for explicit use and parsing.
Update the documentation and cover plain and precompressed file lookup.

Result

Default file serving uses the preferred media type, with the existing
charset and precompression handling. Explicit legacy media types remain
supported.

Tests

Current parser compilation, four selected Scala model cases, a direct Java test method and ten isolated resolver positive cases passed with cached dependencies. Full routing, Scala 3 and full MiMa were not run locally.

GitHub Actions passed on this exact head: Validate and test, Headers, Scalafmt.

References

https://www.rfc-editor.org/rfc/rfc9239.html#section-6.1.1
netty/netty#16036

Motivation:
RFC 9239 identifies text/javascript as the preferred media type for
JavaScript, but the default filename lookup chooses application/javascript.

Modification:
Register text/javascript for .js and .mjs in the Scala and Java models.
Keep application/javascript available for explicit use and parsing.
Update the documentation and cover plain and precompressed file lookup.

Result:
Default file serving uses the preferred media type, with the existing
charset and precompression handling. Explicit legacy media types remain
supported.

References:
https://www.rfc-editor.org/rfc/rfc9239.html#section-6.1.1
netty/netty#16036
@He-Pin
He-Pin force-pushed the fix/javascript-media-type branch from 2fb344e to b8b2be1 Compare November 20, 2026 04:13
@He-Pin
He-Pin marked this pull request as ready for review November 20, 2026 06:30
@He-Pin
He-Pin requested a review from pjfanning November 20, 2026 06:57
@He-Pin
He-Pin merged commit 86e4560 into apache:main Nov 20, 2026
6 checks passed
@He-Pin
He-Pin deleted the fix/javascript-media-type branch November 20, 2026 14:26
pjfanning added a commit that referenced this pull request Nov 21, 2026
Motivation:
The text/javascript, application/manifest+json and audio/aac changes
(#1522, #1523, #1524) put their registry tests in HeaderSpec rather than
MediaTypesSpec, mixed in unrelated control assertions, and scattered
their docs notes through the "Registering Custom Media Types" section.

Modification:
Move the registry tests to MediaTypesSpec, dropping the unrelated
css/unknown-extension/mp3 assertions. Collect the default extension
mappings in a "File Extension Mappings" docs section. Align the
text/javascript val and drop stray blank lines around TEXT_JAVASCRIPT.

Result:
Media type tests and docs live in one place each. No behaviour change.

Tests:
- sbt "http-core / testOnly ...MediaTypesSpec ...HeaderSpec
  ...HttpMessageTest": 50 passed

References:
Refs #1522, #1523, #1524
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