Skip to content

Register WebAssembly and AVIF media types - #1437

Merged
He-Pin merged 1 commit into
apache:mainfrom
He-Pin:feat/wasm-avif-media-types
Nov 17, 2026
Merged

He-Pin merged 1 commit into
apache:mainfrom
He-Pin:feat/wasm-avif-media-types

Conversation

@He-Pin

@He-Pin He-Pin commented Nov 13, 2026

Copy link
Copy Markdown
Member

Summary

Register two additional binary media types and expose matching Scala and Java constants:

  • application/wasm / APPLICATION_WASM, mapped from .wasm, eligible for HTTP compression.
  • image/avif / IMAGE_AVIF, mapped from .avif, marked not compressible like other already-compressed image formats.

The default ContentTypeResolver currently falls back to application/octet-stream for these extensions. Registering them makes ordinary file/resource serving select the appropriate media type without a custom resolver. Both types are binary and are rendered without a charset parameter.

This does not change .js/.mjs handling or register generic HEIF extensions as AVIF.

References

The missing registrations were identified while reviewing Netty #16036. This change follows Pekko's existing media-type registry and API conventions; no Netty implementation or tests were copied.

Validation

  • Test-first: all four new default-resolver checks failed before the registrations, returning application/octet-stream instead of the expected types.
  • After the change: lowercase/uppercase extension resolution, binary/no-charset semantics, compression flags, Scala/Java constant correspondence and typed Content-Type parsing are checked.
  • Independent adversarial review completed.
  • Rebased onto main ee58d2185 and reran verification on Scala 2.13.18 / JDK 17.
  • All 5 targeted ContentTypeResolver.Default tests passed; the existing HttpHeaderSpec Content-Type test group passed.
  • http-core/mimaReportBinaryIssues, both affected source/test header checks, exact-file Scala formatting and http-core/Compile/javafmtCheck passed.
  • git diff --check passed. CI was not inspected or monitored.

@pjfanning pjfanning added this to the 2.1.0 milestone Nov 13, 2026

@pjfanning pjfanning left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks, this looks good. application/wasm as compressible and image/avif as not compressible match how the two formats behave, both are binary (so no charset), and adding the Scala vals and Java constants is binary compatible.

Minor: the first test ("use the registered binary WebAssembly and AVIF media types") largely repeats what the parameterized cases below already check for the resolver. The Java constant and ContentType.parse assertions are the only new parts, and they'd fit better in an http-core model test, since FileAndResourceDirectivesSpec is about routing. Not blocking.

@pjfanning pjfanning left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm

Motivation:
The default file resolver lacks the registered WebAssembly and AVIF media
types. Updating the PR onto current main conflicts with the newly merged
application/zstd resolver tests.

Modification:
Register the Scala and Java media types and their file extensions. Preserve
both the zstd and WebAssembly/AVIF test groups when rebasing onto main.

Result:
The rebased change retains both independent media-type additions without
removing existing registrations or regression coverage.

Tests:
- Rebase diff contains only the original three files and 29 inserted lines.
- Reconciled zstd test block is unchanged; both test groups are retained.
- git diff --check passed.
- Runtime tests were not rerun: JAVA_HOME is unset and javac is unavailable.
- Earlier PR test results do not establish validation of this combined tree.
- CI was not inspected.

References:
Refs apache#1437, apache#1454.
@He-Pin
He-Pin force-pushed the feat/wasm-avif-media-types branch from 9634770 to 7319e29 Compare November 17, 2026 14:23
@He-Pin
He-Pin merged commit 8f514e5 into apache:main Nov 17, 2026
6 checks passed
@He-Pin
He-Pin deleted the feat/wasm-avif-media-types branch November 17, 2026 15:03
pjfanning added a commit that referenced this pull request Nov 19, 2026
Motivation:
Several recently merged PRs left review points unaddressed: docs that
were asked to be dropped, comments and tests that were suggested, and
small API and internal tidy-ups.

Modification:
- Add a Scala FilenameEncoding alias and values to Multipart.FormData
  and use them in the Scala toEntity signature and tests (#1494).
- Render the form-data Content-Disposition header directly instead of
  rendering it twice and slicing off the prefix (#1494).
- Drop the docs paragraph about unpaired URI surrogates (#1426) and the
  cookie -0000 sentence in request-level.md (#1493).
- Fix the javadsl Multipart.FormData doc the same way #1483 fixed the
  scaladsl one.
- Comment the cookie date rule copies so they stay in sync (#1458).
- Test custom methods starting with Q next to the QUERY fast path
  (#1477).
- Use one root package import and a dilated timeout in
  HeaderCompressionSpec (#1438).
- Pass isTrailer to HttpMessageRendering.renderHeaders explicitly
  (#1463).
- Remove the unused forwarding overloads in Handshake.Client and
  EnabledPingState (#1436, #1462).
- Move the media type model checks from the routing spec to a new
  http-core MediaTypesSpec (#1437, #1454).
- Hash the WebSocket key without String.valueOf (#1439).

Result:
The review points are addressed. The only public API change is the
added Scala FilenameEncoding alias.

Tests:
- http-core/testOnly MultipartSpec MultipartsSpec MediaTypesSpec
  RequestParserCRLFSpec RequestParserLFSpec HeaderCompressionSpec
  WebSocketClientSpec HeaderSpec HttpHeaderSpec: 314 passed
- http2-tests/testOnly HttpMessageRenderingSpec Http2PingSchedulingSpec:
  38 passed
- http-tests/testOnly FileAndResourceDirectivesSpec: 63 passed
- http-core/mimaReportBinaryIssues: passed

References:
Refs #1426, #1436, #1437, #1438, #1439, #1454, #1458, #1462, #1463,
#1477, #1483, #1493, #1494
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