Repository navigation
fix: serve JavaScript files as text/javascript - #1522
Merged
Merged
Conversation
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
force-pushed
the
fix/javascript-media-type
branch
from
November 20, 2026 04:13
2fb344e to
b8b2be1
Compare
He-Pin
marked this pull request as ready for review
November 20, 2026 06:30
nvollmar
approved these changes
Nov 20, 2026
This was referenced Nov 20, 2026
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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